Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert a sortedDictionary into Dictionary?

Tags:

c#

generics

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 ;
like image 380
Ujwala Khaire Avatar asked Mar 05 '09 18:03

Ujwala Khaire


1 Answers

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

var dictionary = new Dictionary<type1,type2>(optionsSorted);
like image 74
BFree Avatar answered Oct 22 '22 08:10

BFree