无法使用 ICollection.ToList()
Unable to use ICollection.ToList()
我想在这里打电话给 ToList()
:
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
namespace CSVStuff
{
public static class CSVContentGenerator
{
public static string GetContent(IOrderedDictionary headingsPropertiesMapping)
{
var propertyNames = headingsPropertiesMapping.Keys.ToList(); //ICollection does not contain a definition for ToList()
//var propertyNames = new List<object>(headingsPropertiesMapping.Keys); //Cannot convert from ICollection to int
return "";
}
}
}
为什么这些不起作用?
试试这个:
var propertyNames = headingsPropertiesMapping.Keys.Cast<T>().ToList();
and type T
是字典键的类型。
我想在这里打电话给 ToList()
:
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
namespace CSVStuff
{
public static class CSVContentGenerator
{
public static string GetContent(IOrderedDictionary headingsPropertiesMapping)
{
var propertyNames = headingsPropertiesMapping.Keys.ToList(); //ICollection does not contain a definition for ToList()
//var propertyNames = new List<object>(headingsPropertiesMapping.Keys); //Cannot convert from ICollection to int
return "";
}
}
}
为什么这些不起作用?
试试这个:
var propertyNames = headingsPropertiesMapping.Keys.Cast<T>().ToList();
and type T
是字典键的类型。