Convert IDictionary to Dictionary

Viewed 33330

I have to convert System.Collections.Generic.IDictionary<string, decimal> to System.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) 
3 Answers
var newDictionary = (IDictionary<string, boolean>)ex.Data;

IDictionary can be casted as a Dictionary.

Note that if dictionary is empty/null, it will throw exception.

Related