I'm using the C# CLosedXML package to acquire XML data values and place them into a list. From what I found online, the only example of storing the values into an array in a list is as shown below.
var dataList = new List<string[]>()
{
table.DataRange.Rows().Select(tableRow => tableRow.Field("Story").GetString()).ToArray(),
table.DataRange.Rows().Select(tableRow => tableRow.Field("Level").GetString()).ToArray(),
table.DataRange.Rows().Select(tableRow => tableRow.Field("Combo").GetString()).ToArray(),
table.DataRange.Rows().Select(tableRow => tableRow.Field("Location").GetString()).ToArray(),
table.DataRange.Rows().Select(tableRow => tableRow.Field("Asset").GetString()).ToArray(),
}
I have tried to print the details out in a console to visualize if the data was correctly stored in the list array which I've created. However, the dataList
count is 5. Is it caused by the array size and is there a better way of coding this?
for (int i = 0; i < dataList.Count ; i++)
{
for (int j = 0; j < totalRows; j++)//totalRows more than 10
{
Console.WriteLine("Column {0} details: {1}", i+1, dataList[i][j]);
}
}
Thank you!