Friday, March 14, 2014

C# - CollectionBase - Sorting a collection

Based on my blog post about creating a collection using the CollectionBase class yesterday, I figured out, how to sort a collection based on the class CollectionBase.

public List<MyClass> SortByColumnSortColumn()
{
     List<MyClass> SortedList = this.List.Cast<MyClass>().ToList();
     SortedList = SortedList.OrderBy(x => x.SortColumn).ToList();
     return SortedList;
}

No comments:

Post a Comment