I'm pretty sure I'm missing the obvious answer, but why this:
public static void Foo(IEnumerable<string> strings) { }
public static void Bar<T>(IEnumerable<T> ts)
{
Foo((IEnumerable<string>)ts);
}
is allowed, while this:
public static void Foo(List<string> strings) { }
public static void Bar<T>(List<T> ts)
{
Foo((List<string>)ts);
}
fails with CS0030 Cannot convert type 'System.Collections.Generic<T>' to type 'System.Collections.Generic<string>'.
? Both have the potential to fail at runtime and both have the potential to succeed at runtime. What language rule governs this?