using System.Collections.Generic;
public delegate T DlgSummator<T>(T p1, T p2);
public static void Main(string[] args)
Program p = new Program();
DlgSummator<int> intSummator1 = new DlgSummator<int>( p.SumInt );
DlgSummator<int> intSummator2 = p.SumInt;
Console.WriteLine("intSummator1=" + intSummator1(2, 5));
Console.WriteLine("intSummator2=" + intSummator2(12, 51));
Console.WriteLine("==============");
DlgSummator<string> strSummator1 = new DlgSummator<string>( p.SumStr );
DlgSummator<string> strSummator2 = p.SumStr;
Console.WriteLine("strSummator1=" + strSummator1("Hello", "World"));
Console.WriteLine("strSummator2=" + strSummator2("World", "Hello"));
Console.WriteLine("==============");
List<Customer> custList = new List<Customer>();
custList.Add(new Customer { Id = 1, FirstName = "Joydip", LastName = "Kanjilal", State = "Telengana", City = "Hyderabad", Address = "Begumpet", Country = "India" });
custList.Add(new Customer { Id = 2, FirstName = "Steve", LastName = "Jones", State = "OA", City = "New York", Address = "Lake Avenue", Country = "US" });
Predicate<Customer> hydCustomers = x => (x.Id == 1) || (x.State == "CA");
Func<Customer, bool> fnd = hydCustomers.Invoke;
Func<Customer, bool> fnc = x => (x.Id == 2 ) || (x.State == "NN");
Customer custFound = custList.Find(hydCustomers);
Console.WriteLine(custFound.FirstName);
Console.WriteLine(custList.Count(x => (x.Id==1) || (x.State == "OA")));
Customer[] custArr1 = custList.Where( fnd ).ToArray();
Customer[] custArr2 = custList.Where( x => (x.Id==1) || (x.State == "OA") ).ToArray();
foreach (var c in custArr2)
Console.WriteLine( "Id= " + c.Id + " Fname= " + c.FirstName + " Lname= " + c.LastName + " City=" + c.City);
int SumInt(int i1, int i2)
string SumStr(string i1, string i2)
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }