How do I convert IEnumerable to a custom type in C#?
问题 I am using extension methods OrderBy and ThenBy to sort my custom collection on multiple fields. This sort does not effect the collection but instead returns and IEnumberable. I am unable to cast the IEnumerable result to my custom collection. Is there anyway to change the order of my collection or convert the IEnumerable result to my custom collection? 回答1: If your collection type implements IList<T> (to be able to Add() to it) you could write an extension method: public static Extensions {