简体   繁体   English

将IDictionary转换为Dictionary

[英]Convert IDictionary to Dictionary

I have to convert System.Collections.Generic.IDictionary<string, decimal> to System.Collections.Generic.Dictionary<string, decimal> , and i can't. 我必须将System.Collections.Generic.IDictionary<string, decimal>转换为System.Collections.Generic.Dictionary<string, decimal> ,我不能。 I tried the ToDictionary method and can't specify right arguments. 我尝试了ToDictionary方法,无法指定正确的参数。

I've tried the following: 我尝试过以下方法:

// my dictionary is PlannedSurfaces (of type IDictionary<string, decimal>)
blabla.ToDictionary<string, decimal>(localConstruction.PlannedSurfaces) 

var newDict = new Dictionary<string, decimal>(oldDictionary)

或者在linq

var castedDico = dictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM