Sorry if this is basic. Why cant I add a Dictionary to a another Dictionary? Given the following code:
var mapStudentData = new Dictionary<string, Dictionary<int, List<Student>>>();
var dicValue = new Dictionary<int, List<Student>>();
mapStudentData["strKey"].Add(dicValue);
I get the following errors:
No overload for method 'Add' takes 1 arguments
Any tips on these will be great help. Thanks in advance.
Solved!
I have been using extension methods like below, it run OK ^^
public static void AddRange<T>(this ICollection<T> target, IEnumerable<T> source)
{
if(target==null)
throw new ArgumentNullException("target");
if(source==null)
throw new ArgumentNullException("source");
foreach(var element in source)
target.Add(element);
}
And use like this:
mapStudentData["strKey"].AddRange(dicValue);