在C#中,似乎无法将List对象存储在List变量中,甚至无法明确地进行强制类型转换。
List<string> sl = new List<string>();
List<object> ol;
ol = sl;
结果导致无法隐式转换类型 System.Collections.Generic.List<string>
为 System.Collections.Generic.List<object>
然后是...
List<string> sl = new List<string>();
List<object> ol;
ol = (List<object>)sl;
导致错误:无法将类型 System.Collections.Generic.List<string>
转换为 System.Collections.Generic.List<object>
当然,你可以逐个取出字符串列表中的每个元素并一个一个地放回去,但这是一个相当复杂的解决方案。