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
a=10 b=20
sum=30 pr=200
a=10 b=20 c=30
sum=60 pr=6000
sum=30 pr=200
a=10 b=20 c=30
sum=60 pr=6000