为什么要从界面创建新对象?

时间:2018-05-09 14:57:05

标签: c# collections interface

我看到这经常使用ICollection和IEnumberable完成,看到从Interface而不是类本身创建新对象。为了简单起见,让我们使用IList vs List,因为我更了解这两个。

有什么区别:

IList<string> People = new List<string>();

VS

List<string> People = new List<string>();

与IEnumerable和ICollections类似,您只能使用

Collections<string> People = new Collections<string>(); 

也代替&#34; ICollections&#34;?它太混乱了,为什么要这样做?

0 个答案:

没有答案
相关问题