You need to make a grouping by year like this:
eventsList.GroupBy(x => x.Year)
So later you will be able to iterate through result of code above:
foreach (var eventsInYear in eventsList.GroupBy(x => x.Year))
{
// eventsInYear.Key - year
// eventsInYear - collection of events in that year
}
Related Contents:
- Remove duplicates from a List in C#
- List OrderBy Alphabetical Order
- Merge two (or more) lists into one, in C# .NET
- Getting all file names from a folder using C# [duplicate]
- How to remove item from list in C#?
- How can I convert comma separated string into a List [duplicate]
- Split string, convert ToList() in one line
- Get a list of distinct values in List
- How to add List to a List in asp.net [duplicate]
- How to initialize a List to a given size (as opposed to capacity)?
- ICollection Vs List in Entity Framework
- how to check if object already exists in a list
- Order a List (C#) by many fields? [duplicate]
- Lists: Count vs Count() [duplicate]
- How to remove all the null elements inside a generic list in one go?
- Checking if a list is empty with LINQ
- Does .NET have a way to check if List a contains all items in List b?
- Intelligent way of removing items from a List while enumerating in C#
- IEnumerable vs IReadonlyCollection vs ReadonlyCollection for exposing a list member
- Are 2 dimensional Lists possible in c#?
- Parallel.ForEach with adding to list
- Check if all items are the same in a List
- Why does List.ForEach allow its list to be modified?
- How to get dictionary values as a generic list
- Conversion from List to array T[]
- Saving lists to txt file
- Sum range of int’s in List
- Easiest way to Rotate a List in c#
- Sort one list by another
- Convert DataSet to List
- Differences between IQueryable, List, IEnumerator?
- How to get first object out from List using Linq
- Auto-initializing C# lists
- A method to count occurrences in a list
- Concatenate all list content in one string in C#
- Binding Listbox to List in WinForms
- Storing data into list with class
- What’s the C#-idiomatic way for applying an operator across two lists?
- A list of multiple data types?
- Convert a list of strings to a single string
- Store List to session
- Why is .ForEach() on IList and not on IEnumerable? [duplicate]
- Console.WriteLine and generic List
- Select distinct by two properties in a list
- Standard delegates in C# [closed]
- Return list from async/await method
- populate a dictionary using linq
- HashSet conversion to List
- Best way to dispose a list
- Remove all empty elements from string array