I want to create a Dictionary of <string, Dictionary>
type where the inner Dictionary is of type <string, List<string>>
.
I wrote the following code for that :
using System.IO ;
using System.Collections ;
using System.Collections.Generic ;
class nm {
public static void Main () {
Dictionary<string, Dictionary<string, List<string>>> dicdic = new Dictionary<string, Dictionary<string, List<string>>>();
Dictionary<string, List<string>> fr = new Dictionary<string, List<string>>();
Dictionary<string, List<string>> subdicdic = new Dictionary <string , List<string>>() ;
List<string> p = new List<string>();
p.Add("bro, you feel me ") ;
subdicdic.Add(new KeyValuePair<string, List<string>>("ll", p));
fr.Add(new KeyValuePair("foo", subdicdic)) ;
}
}
But on trying to compile it with csc in windows command prompt , I am getting a compilation error at line 18 which is the following :
fr.Add(new KeyValuePair("foo", subdicdic)) ;
stating the following :
"No overload for method 'Add' takes '1' arguments "
I surfed up for similar questions on c# and I got the following question :
But after going through this I am getting a feel there might be some restriction for using list variable name in place of the list . But I am not sure .
I went through the following question too :
Adding a key value pair in a dictionary inside a dictionary
Although the above might help in getting an alternative solution for the purpose code that I am trying to write .
But for now I want to know what stops me from adding this list as a value for the dictionary .
The version details of my compiler :
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.8922 for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
What might be the issue here ? How to operate with a dictionary having an internal dictionary with list in .net 2.0 ?