using System.Collections.Generic;
public static void Main()
IsTeenAger isTeenAger = delegate(Student s) { return s.Age > 12 && s.Age < 20; };
Student stud = new Student() { Age = 25 };
Console.WriteLine(isTeenAger(stud));
IsTeenAger isTeenAger2 = s => s.Age > 12 && s.Age < 30;
Console.WriteLine(isTeenAger2(stud));
IsYoungerThan isYoungerThan = (s, youngAge) => s.Age < youngAge;
Student stud2 = new Student() { Age = 25 };
Console.WriteLine(isYoungerThan(stud2, 26));
Print print = () => Console.WriteLine("This is parameter less lambda expression");
IsYoungerThan isYoungerThan2 = (s, youngAge) => {
Console.WriteLine("Lambda expression with multiple statements in the body");
Student stud3 = new Student() { Age = 25 };
Console.WriteLine(isYoungerThan(stud3, 26));
IsAdult isAdult = (s) => {
Console.WriteLine("Lambda expression with multiple statements in the body");
return s.Age >= adultAge;
Student stud4 = new Student() { Age = 25 };
Console.WriteLine(isAdult(stud4));
Func<Student, bool> isStudentTeenAger = s => s.Age > 12 && s.Age < 20;
Student stud5 = new Student() { Age = 21 };
Console.WriteLine(isStudentTeenAger(stud5));
Action<Student> PrintStudentDetail = s => Console.WriteLine("Name: {0}, Age: {1} ", s.Name, s.Age);
Student std = new Student(){ Name = "Bill", Age=21};
public int StudentID { get; set;}
public String StudentName { get; set;}
public int Age { get; set;}
public string Name { get; set; }
public int Id { get; set; }
delegate bool IsTeenAger(Student stud);
delegate bool IsYoungerThan(Student stud, int youngAge);
delegate bool IsAdult(Student stud);