shanselman / SmallestDotNet

SmallestDotNet - SmallestDotNet.com is a single page site that does one thing. It tells you the smallest, easiest download you'd need to get the .NET Framework on your system.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First() on a Dictionary?

peterfoldi opened this issue · comments

Hi Scott,

I am sure time proved that this code works as expected but it looks strange for me:

installedVersions = installedVersions.OrderByDescending(p => p.Value.Major)
                .ThenByDescending(p => p.Value.Minor)
                .ThenByDescending(p => p.Value.Profile)
                .ThenByDescending(p => p.Value.ServicePack ?? 0)
                .ToDictionary(p => p.Key, p => p.Value);

if (installedVersions.Any())
{
    return installedVersions.First().Value;
}

Calling First() on a Dictionary shouldn't be a deterministic way to get the largest element from a Dictionary, or do I miss something here?

The dictionary is created and ordered from a dictionary that is built from a string, version pair.