Convert IDictionary to Dictionary
30,726
Solution 1
var newDict = new Dictionary<string, decimal>(oldDictionary)
Solution 2
or in linq
var castedDico = dictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
Author by
croisharp
Updated on May 08, 2021Comments
-
croisharp almost 3 years
I have to convert
System.Collections.Generic.IDictionary<string, decimal>
toSystem.Collections.Generic.Dictionary<string, decimal>
, and i can't. I tried the ToDictionary method and can't specify right arguments.I've tried the following:
// my dictionary is PlannedSurfaces (of type IDictionary<string, decimal>) blabla.ToDictionary<string, decimal>(localConstruction.PlannedSurfaces)