是否有特殊的方法來初始化IList<T>
?這似乎並不工作:初始化IList <T> C#
IList<ListItem> allFaqs = new IList<ListItem>();
// Error I get here: Cannot create an instance of the interface 'IList<ListItem>'
ReSharper的建議將其初始化像這樣:
IList<ListItem> allFaqs = null;
,但不會導致一個空引用異常時,我去項目添加到這個列表?
或者我應該只使用List<ListItem>
?
謝謝!
爲我節省了很多時間,謝謝:) – Sijav 2015-03-26 02:22:12