using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;
public string StudentName
public static class EnumerableExtensionMethods
public static IEnumerable<Student> GetTeenAgerStudents(this IEnumerable<Student> source)
foreach (Student std in source)
Console.WriteLine("Accessing student {0}", std.StudentName);
if (std.Age > 12 && std.Age < 20)
public static void Main()
IList<Student> studentList = new List<Student>()
StudentID = 1, StudentName = "John", Age = 13
StudentID = 2, StudentName = "Steve", Age = 15
StudentID = 3, StudentName = "Bill", Age = 18
StudentID = 4, StudentName = "Ram", Age = 12
StudentID = 5, StudentName = "Ron", Age = 21
from s in studentList.GetTeenAgerStudents()select s;
studentList.Add(new Student(){StudentID = 6, StudentName = "Tayo", Age = 15});
foreach (Student teenStudent in teenAgerStudents)
Console.WriteLine("Student Name: {0}", teenStudent.StudentName);