Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jondjones/2c66601607afe8b475fd2f5c5ffdae36 to your computer and use it in GitHub Desktop.
Save jondjones/2c66601607afe8b475fd2f5c5ffdae36 to your computer and use it in GitHub Desktop.
7 New Linq Methods You Need To Know About - 8
var fruits = new List<string> { "apple", "banana", "apple", "orange", "banana", "apple" };
var fruitCount = fruits.GroupBy(fruit => fruit)
.Select(group => new { Fruit = group.Key, Count = group.Count() })
.ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment