44
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
// Student collection
11
IList<Student> studentList = new List<Student>() {
12
new Student() { StudentID = 1, StudentName = "John", Age = 18 } ,
13
new Student() { StudentID = 2, StudentName = "Steve", Age = 15 } ,
14
new Student() { StudentID = 3, StudentName = "Bill", Age = 25 } ,
15
new Student() { StudentID = 4, StudentName = "Ram" , Age = 20 } ,
16
new Student() { StudentID = 5, StudentName = "Ron" , Age = 19 }
17
};
18
19
var studentsInAscOrder = studentList.OrderBy(s => s.StudentName);
20
21
var studentsInDescOrder = studentList.OrderByDescending(s => s.StudentName);
22
23
24
Console.WriteLine("Ascending Order:");
Cached Result
Dumping object(Response`1[Employee])
Item :
{
FirstName : Test
LastName : Test_Last
}
Status : False
Dumping object(Response`1[Student])
Item :
{
Age : 35
FullName : john doe
}
Status : False
Item :
{
FirstName : Test
LastName : Test_Last
}
Status : False
Dumping object(Response`1[Student])
Item :
{
Age : 35
FullName : john doe
}
Status : False