I have the following class file where all properties are defined as follows
public class DataDto
{
public ImmutableList<string> Header;
public ImmutableList<ImmutableList<string> Rows;
}
I would like to add values to the to both properties but I do not know how to do that. I am learning c# and would like to know how to do that. In my program.cs file I am doing the following but I get a Object reference not set to an instance of an object exception
var mydata = new DataDto();
var headerList = new List<string>();
var rowList = new List<string>();
headerList.Add("1");
headerList.Add("2");
headerList.Add("3");
rowList.Add("4");
rowList.Add("5");
rowList.Add("6");
mydata.Header.AddRange(headerList);
foreach (var value in mydata.Header)
{
Console.WriteLine(value);
}
I would also like to fill in the rows as well with the object.