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? If your collection type implements IList<T> (to be able to Add() to it) you could write an extension method: public static Extensions { public static TColl ToTypedCollection<TColl, T>(this IEnumerable ien) where TColl : IList<T>, new() { TColl