【发布时间】:2016-09-08 14:04:46
【问题描述】:
我有以下代码,它会抛出错误:
无法将类型“System.Collections.Generic.Dictionary>”隐式转换为 'System.Collections.Generic.Dictionary>'
我希望编译器能够理解 IEnumerable 和 List 是兼容的,但它会引发错误。请解释一下为什么会这样?
Dictionary<string, List<DataRow>> sampleData = new Dictionary<string, List<DataRow>>();
Dictionary<string, IEnumerable<DataRow>> schedules = sampleData;
谢谢!
【问题讨论】:
-
Lists 和 Ienums 兼容但不一样,需要强制转换或更改为相同
-
我不认为字典是共同变量
标签: c#