I have the following code that creates an extension to an IEnumerable<T>
:
//http://stackoverflow.com/a/1779135/1180926
public static IEnumerable<T> SkipLast<T>(this IEnumerable<T> source, int n)
{
//.......
}
When I try to apply this to a list:
public static void RemoveTwo(List<string> strList)
{
strList = strList.SkipLast(2);
}
I get the following error:
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.List'. An explicit conversion exists (are you missing a cast?)
But List<T>
inherits IEnumerable<T>
(src), so shouldn't it also inherit its extension methods?