Working on a .net 2.0 project and no linq and cannot add any external library.
Build a small example of what I need to do in my real project.
How do you group by eg “Employee.Category” without using linq.
For each group I need to do something about it.
How do you group by in .net 2.0?
class Program
{
static void Main(string[] args)
{
List<Employee>employees=new List<Employee>();
Employee employee = new Employee();
employee.Id = 1;
employee.Category = "Management";
Employee employee2 = new Employee();
employee.Id = 2;
employee.Category = "Management";
Employee employee3 = new Employee();
employee.Id = 3;
employee.Category = "Director";
Employee employee4 = new Employee();
employee.Id = 4;
employee.Category = "Worker";
Employee employee5= new Employee();
employee.Id = 5;
employee.Category = "Director";
Employee employee6 = new Employee();
employee.Id = 6;
employee.Category = "Worker";
employees.AddRange(new Employee[] { employee, employee2, employee3, employee4, employee5, employee6 });
//1)Group them by category in .net 2.O NO LINQ
//2)Foreach item in the group do something.
Console.WriteLine("??");
}
}
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
}
Thanks for any suggestions
How about: