Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#Linq将匿名对象选择到字典中_C#_Linq_Configuration_Ienumerable - Fatal编程技术网

C#Linq将匿名对象选择到字典中

C#Linq将匿名对象选择到字典中,c#,linq,configuration,ienumerable,C#,Linq,Configuration,Ienumerable,我创建了一个自定义配置部分,其中包含一组键值对。这一切都很好,我可以找回元素。然后,我需要做的是选择字典中的每个元素。我已经在我的ConfigurationCollectionElement上实现了IEnumerable,并且再次正确填充了变量元素。但是,下面的代码不会编译。错误是: “System.Collections.Generic.IEnumerable”没有 包含“ToDictionary”的定义 这显然不是事实,因为有大量的例子表明了这一点。这是怎么回事 { var prob

我创建了一个自定义配置部分,其中包含一组键值对。这一切都很好,我可以找回元素。然后,我需要做的是选择字典中的每个元素。我已经在我的
ConfigurationCollectionElement
上实现了
IEnumerable
,并且再次正确填充了变量元素。但是,下面的代码不会编译。错误是:

System.Collections.Generic.IEnumerable
”没有 包含“
ToDictionary
”的定义

这显然不是事实,因为有大量的例子表明了这一点。这是怎么回事

{
    var problemDirectory = new Dictionary<string,object>();

    var coreOperands = ConfigurationManager.GetSection("RuntimeCoreOperands") as OperandConfigurationSection;

    var elements = coreOperands.Operands.Select(op => new { Name = op.Name, Symbol = op.Symbol });

    this.problemDirectory = elements.ToDictionary<string, object>(op => op.Name, op => op.Symbol);
}        
{
var problemDirectory=new Dictionary();
var coreOperators=ConfigurationManager.GetSection(“RuntimeCoreOperators”)作为操作数配置节;
var elements=coreOperators.operators.Select(op=>new{Name=op.Name,Symbol=op.Symbol});
this.problemDirectory=elements.ToDictionary(op=>op.Name,op=>op.Symbol);
}        

您是否使用System.Linq添加了
?尝试删除
@TimSchmelter如果
符号
不是
对象
,但字段类型是
字典
,则没有它就无法编译。