简体   繁体   中英

How to Declare an Array of Generic Dictionaries in C#?

I want to create an array of Dictionaries. But the array size is unknown. For integer, i used List to obtain the integer array of unknown size. But in the case of Dictionary, am not able to create a list of Dictionary. Is thr any wayz by which this can be done?
Dictionary(int, String) paramList=null;
I am want to create the array of paramList(above). I am using C Sharp.

List<Dictionary<int, String>> paramList = new List<Dictionary<int, String>>();

However, this is usually not the right data structure. More likely, you just need a single dictionary.

Dictionary<int, String> paramList = new Dictionary<int, String>();
paramList[1] = "foo";
paramList[2] = "bar";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM