Skip to content

Instantly share code, notes, and snippets.

@fresky
Created September 12, 2012 01:04
Show Gist options
  • Save fresky/3703421 to your computer and use it in GitHub Desktop.
Save fresky/3703421 to your computer and use it in GitHub Desktop.
ToDictionary
List<People> peoples = new List<People>();
for (int i = 0; i < 10; i++)
{
peoples.Add(new People() { Name = i.ToString() });
}
foreach (var source in peoples.ToDictionary(people => people.Name))
{
Console.WriteLine(source.Key);
Console.WriteLine(source.Value);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment