Copy ResourceDictionary to Dictionary in C #

I have a ResourceDictionary containing only string keys and string values. Now I want to have a dictionary <string, string> with the same contents.

How do you do this? What is the fastest solution in C #?

Edit: The fastest in terms of performance;)

+4
source share
1 answer

The fastest in terms of the simplest? Assuming .NET 3.5 (and therefore LINQ), I would use:

resourceDictionary.Keys.Cast<string>().ToDictionary (x => x, // Key selector x => (string) resourceDictionary[x] // Value selector ); 
+9
source

All Articles