You can do something like this:
int i = 0;
foreach (var grouping in Class.Students.GroupBy(s => ++i / 20))
Console.WriteLine("You belong to Group " + grouping.Key.ToString());
More Related Contents:
- Performance loss caused by Linq [duplicate]
- Is a LINQ statement faster than a ‘foreach’ loop?
- Update all objects in a collection using LINQ
- Linq style “For Each” [duplicate]
- Get All instead of FirstOrDefault
- How to write this nested foreach loop query in LINQ?
- Group by in LINQ
- Linq: GroupBy, Sum and Count
- LINQ to Entities does not recognize the method ‘System.String ToString()’ method, and this method cannot be translated into a store expression
- Find an item in a list by LINQ
- How to get values of selected items in CheckBoxList with foreach in ASP.NET C#?
- Has foreach’s use of variables been changed in C# 5?
- Performance difference for control structures ‘for’ and ‘foreach’ in C#
- Combination of List
- LINQ Select Distinct with Anonymous Types
- LINQ Orderby Descending Query
- How to get the closest number from a List with LINQ?
- Multiple Order By with LINQ [duplicate]
- Extension methods syntax vs query syntax
- How do I create an expression tree calling IEnumerable.Any(…)?
- Convert string to int array using LINQ [duplicate]
- C# Linq where clause as a variable
- Find if listA contains any elements not in listB
- Find all child controls of specific type using Enumerable.OfType() or LINQ
- Why can’t we assign a foreach iteration variable, whereas we can completely modify it with an accessor?
- Split an IEnumerable into fixed-sized chunks (return an IEnumerable where the inner sequences are of fixed length) [duplicate]
- Remove item from list based on condition
- Select multiple fields group by and sum
- C# Searching for files and folders except in certain folders
- What is the difference between LINQ ToDictionary and ToLookup