I have a list and I want to copy three other lists into it.
// The main list
List<List<string>> list= new List<List<string>>();
// The lists which I want to combine
ArrayList sublist1= new ArrayList();;
ArrayList sublist2= new ArrayList();;
ArrayList sublist3= new ArrayList();;
What I tried is:
list[0].AddRange(sublist1);
list[0].AddRange(sublist2);
list[0].AddRange(sublist3);
It doesn't work because It is multidimensional list. I need this type of list for the future plans.
How can I accomplist it?
sublist2twice, etc).. what is the real code and what is the error message / exception / incorrect result / unexplained observed behavior? (And what is the desired result?)The best overloaded method match for 'System.Collections.Generic.List<string>.AddRange(System.Collections.Generic.IEnumerable<string>)' has some invalid argumentsIEnumerable<string>.ArrayListdoes not. Nothing to do with multidimensionalisms. Perhaps:list[0].AddRange(sublist1.Cast<string>())(make sure to "using" Linq) .. or better, well-type the "sublists" (e.g.List<string> sublist1 = ..).