【发布时间】:2022-04-22 03:53:12
【问题描述】:
我尝试这样做:
IEnumerable<object> ids = new List<string>() { "0001", "0002", "0003" };
效果很好!
但是当我尝试这样做时:
IEnumerable<object> intIds = new List<System.Int32>() { 1, 2, 3 };
Visual Studio 告诉我: 无法将类型“System.Collections.Generic.List”隐式转换为“System.Collections.Generic.IEnumerable”。存在显式转换(您是否缺少演员表?)
这是为什么呢?
【问题讨论】:
标签: .net-4.0 ienumerable covariance value-type