如何轉換的IList到IList中使用的協方差在C#ISomeInterface 4.0如何轉換的IList <SomeObject>到的IList <ISomeInterface>其中SomeObject實現使用協方差在C#ISomeInterface 4.0
我有類似的東西以下
其中SomeObject實現IList<Items> GetItems;
IList<IItems> items = GetItems() as IList<IItems>;
但項目爲空;
答案這裏是爲前4.0:
Converting an array of type T to an array of type I where T implements I in C#
是的,爲什麼不呢!唯一的原因是我沒有想到這一點。 TX – Arjang 2011-04-10 21:25:24