1. List of Employees grouped by the first letter of their FirstNameTo display a list of employees group by the first alphabet of their FirstName, use this query
C#
// Group People by the First Letter of their FirstName
var grpOrderedFirstLetter = empList.GroupBy(employees =>
new String(employees.FName[0], 1)).OrderBy(employees => employees.Key.ToString());;
foreach (var employee in grpOrderedFirstLetter)
{
Console.WriteLine("\n'Employees having First Letter {0}':", employee.Key.ToString());
foreach (var empl in employee)
{
Console.WriteLine(empl.FName);
}
}
Console.ReadLine();
VB.NET
' Group People by the First Letter of their FirstName
Dim grpOrderedFirstLetter = empList.GroupBy(Function(employees) New String(employees.FName(0), 1)).OrderBy(Function(employees) employees.Key.ToString())
For Each employee In grpOrderedFirstLetter
Console.WriteLine(Constants.vbLf & "'Employees having First Letter {0}':", employee.Key.ToString())
For Each empl In employee
Console.WriteLine(empl.FName)
Next empl
Next employee
Console.ReadLine()
cont..,
Post a Comment