如何將sortedDictionary轉換為字典? - How to convert a sortedDictionary into Dictionary? -开发者知识库

如何將sortedDictionary轉換為字典? - How to convert a sortedDictionary into Dictionary? -开发者知识库,第1张

Dictionary<string, string> optionDictionary = new Dictionary<string, string>();

optionDictionary = ....;

SortedDictionary<string, string> optionsSorted;

if(sorting)
{
   optionsSorted = new SortedDictionary<string, string>(optionDictionary );
   // Convert SortedDictionary into Dictionary
}

return optionDictionary ;

4 个解决方案

#1


You can pass in your optionsSorted<TKey,TValue> dictionary as a parameter to an instance of a new Dictionary<TKey,TValue>, Like so:

您可以將optionsSorted 字典作為參數傳遞給新Dictionary 的實例,如下所示:

var dictionary = new Dictionary<type1,type2>(optionsSorted);

最佳答案:

本文经用户投稿或网站收集转载,如有侵权请联系本站。

发表评论

0条回复