I have a ResourceDictionary only containing string keys and string values. Now I want to have a Dictionary< string, string > with the same content.
How would you do that? Whats the fastest solution in C#?
Edit: Fastest in terms of perfomance ;)
I have a ResourceDictionary only containing string keys and string values. Now I want to have a Dictionary< string, string > with the same content.
How would you do that? Whats the fastest solution in C#?
Edit: Fastest in terms of perfomance ;)
Fastest in terms of simplest? Assuming .NET 3.5 (and thus LINQ) I'd use:
resourceDictionary.Keys.Cast<string>().ToDictionary
(x => x, // Key selector
x => (string) resourceDictionary[x] // Value selector
);