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.
私のシナリオ、
に変換する方法List<KeyValuePair<string, string>>は IDictionary<string, string>?
List<KeyValuePair<string, string>>
IDictionary<string, string>
非常に、非常に単純に LINQ を使用します。
IDictionary<string, string> dictionary = list.ToDictionary(pair => pair.Key, pair => pair.Value);
重複するキーがある場合、これは失敗することに注意してください-大丈夫だと思いますか?
クラスToDictionary()の拡張メソッドを使用します。Enumerable
ToDictionary()
Enumerable