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 = 5, studentName = "Ron" , Age = 31 },
new student() { studentID = 6, studentName = "Chris", Age = 17 },
new student() { studentID = 7, studentName = "Rob",Age = 19 },
new student() { studentID = 8, studentName = "Rob",Age = 21 },
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 = 9, studentName = "Bill",Age = 19 },
};
// var list = li.OrderBy(x => x.studentID).ToList();
// var list = li.OrderByDescending(x => x.studentName).ToList();
// var list = li.OrderByDescending(x => x.studentName).ThenBy(x=>x.Age).ToList();
var list = li.OrderByDescending(x => x.studentName).ThenByDescending(x=>x.Age).ToList();
foreach (var item in list)
{
Console.WriteLine("id: "+item.studentID+"---Name: "+item.studentName+"---age:"+item.Age);
}
}
}
}
--------------------------------------------------------------------------------------------------------------
public int studentID { get; set; }
public string studentName { get; set; }
public int Age { get; set; }
No comments:
Post a Comment