34
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
5
namespace ConsoleApplication1
6
{
7
internal class Student
8
{
9
public int ID { get; set; }
10
public string Name { get; set; }
11
public int Age { get; set; }
12
}
13
14
public class Program
15
{
16
public static void Main(string[] args)
17
{
18
List<Student> students = new List<Student>();
19
students.Add(new Student { ID = 1, Name = "Kapil", Age = 22 });
20
students.Add(new Student { ID = 2, Name = "Ramesh", Age = 17 });
21
students.Add(new Student { ID = 3, Name = "Raj", Age = 24 });
22
students.Add(new Student { ID = 4, Name = "Anil", Age = 25 });
23
24
if (students.Any(w => w.Age < 18))
25
{
26
Console.WriteLine("There are minor students in list.");
27
}
28
else
29
{
30
Console.WriteLine("No minor students");
31
}
32
}
33
}
34
}
Cached Result