namespace SampleApp
{
class Employee
{
public string FirstName { get; set; }
public string LastName { get; set; }
public int Age { get; set; }
}
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
List<Employee> list = new List<Employee>(){
new Employee() { FirstName="Himanshu", LastName="Manjarawala", Age=30},
new Employee(){ FirstName="Hetal", LastName="Sangani", Age=26},
new Employee(){ FirstName="Viral", LastName="Sangani", Age=32},
new Employee(){ FirstName="Rajesh", LastName="Patel", Age=29},
new Employee(){ FirstName="Nehal", LastName="Thakkar", Age=30}
};
//Lemda notation
var n = list.Where(o => o.FirstName.StartsWith("H"));
//Notation using delegate
var d = list.Where(delegate(Employee o) { return o.FirstName.StartsWith("H"); });
//Notation using Func<> delegate
var f = list.Where(delegate(Employee o) { return MySelect(o); });
foreach (Employee o in n)
{
System.Diagnostics.Debug.Print("Lemda: [ FirstName:{0}, LastName:{1}, Age:{2} ]", o.FirstName, o.LastName, o.Age);
}
foreach (Employee o in d)
{
System.Diagnostics.Debug.Print("Delegate: [ FirstName:{0}, LastName:{1}, Age:{2} ]", o.FirstName, o.LastName, o.Age);
}
foreach (Employee o in f)
{
System.Diagnostics.Debug.Print("Func<> Delegate: [ FirstName:{0}, LastName:{1}, Age:{2} ]", o.FirstName, o.LastName, o.Age);
}
}
}
}