Is there a function I can use to initialize Multiple List by using a given name List? For example:
List<string> nw_TCList = new List<string>();
List<string> ia_TCList = new List<string>();
List<string> st_TCList = new List<string>();
List<string> ud_TCList = new List<string>();
List<string> mb_TCList = new List<string>();
I would like to create thoese List, right now i have a List contains thoese name:
List<string> myNameList = new List<string>()
{
"nw_TCList",
"ia_TCList",
"st_TCList",
"ud_TCList",
"mb_TCList"
};
I want to do something like this:
for (int i = 0; i < myNameList.Count(); i++)
{
List<string> myNameList[i] = new List<string>();
}
Furthermore, Assume I have a dictionary myDic<sting,List<string>>, i have a Key list List<string> myKeys and many List<string> that i just created. I want to add them to the Dictionary something like this:
myDic.Add(myKeys[0], nw_TCList);
myDic.Add(myKeys[1], ia_TCList);
myDic.Add(myKeys[2], st_TCList);
myDic.Add(myKeys[3], ud_TCList);
myDic.Add(myKeys[4], mb_TCList);
Is there any easy way to do this job? Thanks a lot.
xx_TCListvariables in the first place is the way to go. Why do you have those?