You can use Cast<T>()
or OfType<T>
to get a generic version of an IEnumerable that fully supports LINQ.
Eg.
IEnumerable objects = ...;
IEnumerable<string> strings = objects.Cast<string>();
Or if you don't know what type it contains you can always do:
IEnumerable<object> e = objects.Cast<object>();
If your non-generic IEnumerable
contains objects of various types and you are only interested in eg. the strings you can do:
IEnumerable<string> strings = objects.OfType<string>();
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…