This is my code, I want to sort in descending order based on Name.

List<Employee> objemployee = new List<Employee>(){
            new Employee() {  Name = "Suresh",Skills  = "C"},
            new Employee() {  Name = "Rohini", Skills=  "SQL Server" },
              new Employee() {  Name = "Amit", Skills=  "SQL" },
            new Employee() {  Name = "Pankaj", Skills=  "ASP.NET" },
            new Employee() {  Name = "Suresh", Skills=  "MVC" }};
 
            var result =objemployee.OrderBy(x => x.Name);

please help me how to do it.

1 Answers

  1. Aditya Kumar Patel
    sort a list in descending order in linq arya mercy
    9/22/2018 3:33:58 PM

    Try to use it:

    List<Employee> objemployee = new List<Employee>(){
                new Employee() {  Name = "Suresh", Skills  = "C"},
                new Employee() {  Name = "Rohini", Skills =  "SQL Server" },
                  new Employee() {  Name = "Amit", Skills =  "SQL" },
                new Employee() {  Name = "Pankaj", Skills =  "ASP.NET" },
                new Employee() {  Name = "Suresh", Skills =  "MVC" }};
     
    var result =objemployee.OrderByDescending(x => x.Name);

    I hope it will help to you.


Leave a answer

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like