[英]Convert IDictionary to Dictionary
我必須將System.Collections.Generic.IDictionary<string, decimal>
轉換為System.Collections.Generic.Dictionary<string, decimal>
,我不能。 我嘗試了ToDictionary方法,無法指定正確的參數。
我嘗試過以下方法:
// 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.