using System.Collections.Generic;
public static void Main()
IList<Student> studentList = new List<Student>()
new Student() { StudentID = 1, StudentName = "John", Age = 13 } ,
new Student() { StudentID = 2, StudentName = "Steve", Age = 15 } ,
new Student() { StudentID = 3, StudentName = "Bill", Age = 18 } ,
new Student() { StudentID = 4, StudentName = "Ram" , Age = 12 } ,
new Student() { StudentID = 5, StudentName = "Ron" , Age = 21 }
var teenAgerStudents = studentList.GetTeenAgerStudents();
foreach(var teenStudent in teenAgerStudents)
Console.WriteLine("Student Name: {0}", teenStudent.StudentName);
public int StudentID { get; set; }
public string StudentName { get; set; }
public int Age { get; set; }
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)