【发布时间】:2009-11-20 19:04:02
【问题描述】:
为什么不能编译?
public interface IConcrete { }
public class Concrete : IConcrete { }
public class Runner
{
public static void Main()
{
var myList = new List<Concrete>();
DoStuffWithInterfaceList(myList); // compiler doesn't allow this
}
public static void DoStuffWithInterfaceList(List<IConcrete> listOfInterfaces) { }
}
将 myList 设置为正确类型的最快方法是什么?
编辑 我搞砸了 DoStuffWithInterfaceList 示例
【问题讨论】:
-
有人对此有任何更新吗?十年后还是一样的答案?
标签: c#