I am attempting to create a class of lists
public class comparisonData
{
public List<string> Tables { get; set; }
public List<string> Constraints { get; set; }
public List<string> StoredProcs { get; set; }
public List<string> Views { get; set; }
public List<string> Functions { get; set; }
public List<string> Columns { get; set; }
public List<string> Synonyms { get; set; }
public List<string> NotNullables { get; set; }
}
And then instantiate said class as a list
List<comparisonData> cList = new List<comparisonData>();
My end goal is to have a list of several different database names which each have Lists that contain said databases table names, columns, constraints etc.
However I am receiving an "Index was out of range. Must be non-negative and less than the size of the collection" error when I try to populate my lists
while(reader.Read())
{
cList[0].Tables.Add(reader.GetString(0));
}
Am I instantiating something wrong? Or is this list of lists just bad code and I should pursue a different mean to my end goal?