Question

Please refer below code

public class NNAEmployeeDetails
    {
        public string DealerCode { get; set; }
        public string EmployeeCode { get; set; }
        public string EmployeeName { get; set; }
}

IEnumerable<NNAEmployeeDetails> empList =GetList();

i am trying the sort the above ienumerable by Employeename by below code

empList.OrderBy(s=>s.EmployeeName)

but OrderBy itself not showing in empList. Please refer below image

enter image description here

why the OrderBy is not coming in empList ? is any namespace problem ? what is the exact behavior ? how to sort ienumerable by EmployeeName ?

Was it helpful?

Solution

You need to have a using for System.Linq to access the LINQ extension methods.

Also note that OrderBy doesn't mutate the sequence, it creates a new sequence that is ordered.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top