c# list object sort alphabetically

63

c# list object sort alphabetically -

using System.Linq;

List<MyObject> list = new List<MyObject>()
{ new MyObject("Peterson", "Mike"), new MyObject("Johnson", "Tim") };

list.OrderBy((item) => item.LastName);
// In this example, the list would be arranged like so: Johnson, Peterson

Comments

Submit
0 Comments