Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个仅包含字符串键和字符串值的 ResourceDictionary。现在我想要一个具有相同内容的 Dictionary< string, string >。
你会怎么做?C# 中最快的解决方案是什么?
编辑:在性能方面最快;)
就最简单而言最快?假设.NET 3.5(以及LINQ)我会使用:
resourceDictionary.Keys.Cast<string>().ToDictionary (x => x, // Key selector x => (string) resourceDictionary[x] // Value selector );