using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<student> li = new List<student>()
{
new student() { studentID = 1, studentName = "John", Age = 18 },
new student() { studentID = 2, studentName = "Steve", Age = 21 },
new student() { studentID = 3, studentName = "Bill", Age = 25 },
new student() { studentID = 4, studentName = "Ram" , Age = 20 },
new student() { studentID = 5, studentName = "Ron" , Age = 31 },
new student() { studentID = 6, studentName = "Chris", Age = 17 },
new student() { studentID = 7, studentName = "Rob",Age = 19 },
};
List<student> teenagerlist = li.Where(x => x.Age > 12 && x.Age < 20).ToList();
Console.WriteLine("Teenager students: ");
foreach (student item in teenagerlist)
{
Console.WriteLine("Name: "+item.studentName);
}
}
}
}
----------------------------------------------------------------------------------------------------------------
class student
{
public int studentID { get; set; }
public string studentName { get; set; }
public int Age { get; set; }
}