51
1
using System;
2
using System.Linq;
3
using System.Collections.Generic;
4
5
6
public class Program
7
{
8
public static void Main()
9
{
10
IList<Student> studentList = new List<Student>() {
11
new Student() { StudentID = 1, StudentName = "John", Age = 18 } ,
12
new Student() { StudentID = 2, StudentName = "Steve", Age = 15 } ,
13
new Student() { StudentID = 3, StudentName = "Bill", Age = 25 } ,
14
new Student() { StudentID = 3, StudentName = "Bill", Age = 25 } ,
15
new Student() { StudentID = 3, StudentName = "Bill", Age = 25 } ,
16
new Student() { StudentID = 3, StudentName = "Bill", Age = 25 } ,
17
new Student() { StudentID = 5, StudentName = "Ron" , Age = 19 }
18
};
19
20
21
var distinctStudents = studentList.Distinct(new StudentComparer());
22
23
foreach(var std in distinctStudents)
24
Console.WriteLine(std.StudentName);
Cached Result