c# sort a list by a column alphabetically

后端 未结 2 2004
小蘑菇
小蘑菇 2021-01-25 10:49

I have a class defined and I write records to this class to a List. Having trouble sorting the list before I write an error report. I\'m trying to sort the list alphabetically b

2条回答
  •  我在风中等你
    2021-01-25 10:53

    Firstly its just

    List1.Sort();
    

    Sort method return nothing. It just sorts the list.

    Secondly if you want to sort based on a property do this

    List sortedlist = List1.OrderBy(x => x.finderror).ToList();
    

提交回复
热议问题