This seems correct :
IList<IList<string>> MyList = new List<IList<string>>();
IList<string> List_Temp = new List<string>();
MyList .Add(List_Temp );
This seems incorrect :
IList<List<string>> MyList = new List<List<string>>();
IList<string> List_Temp = new List<string>();
MyList .Add(List_Temp );
why the second is incorrect?
Because you’re trying to add some
IListimplementation istead ofListclass, which is requirement by definition – IList<List>. Look at this:The second line of sample is correct, because
Collection<T>implementsIList<T>, but the third line is incorrect, becauseCollection<T>doesn’t inheritList<T>.