c# - How can I convert a ConcurrentDictionary to a Dictionary? -
i have concurrentdictionary object set dictionary object.
casting between them not allowed. how do it?
the concurrentdictionary<k,v>
class implements idictionary<k,v>
interface, should enough requirements. if need concrete dictionary<k,v>
...
var newdictionary = yourconcurrentdictionary.todictionary(kvp => kvp.key, kvp => kvp.value, yourconcurrentdictionary.comparer); // or... // substitute actual key , value types in place of tkey , tvalue var newdictionary = new dictionary<tkey, tvalue>(yourconcurrentdictionary, yourconcurrentdictionary.comparer);
Comments
Post a Comment