I need to create a list of integer arrays. I know ahead of time the length of the arrays, but I don't know how many of them need to be added to the list.
I've tried the following code:
List<int[]> MyListOfArrays = new List<int[]>();
int[] temp = new int[30];
range = xlApp.get_Range("NamedRange");
values = (object[,])range.Value2;
for (int i = 0; i < values.GetLength(0); i++)
{
for (int j = 0; j < values.GetLength(1); j++)
{
temp[j] = Convert.ToInt32(values[i + 1, j + 1]);
}
MyListOfArrays.Add(temp);
}
The temp array is filled just fine. However, MyListOfArrays just ends up with the last iteration of temp repeated for all of the entries. Where am I going wrong?
List<int[]>might make sense. I don't have enough info to know whether this is a valid case, or would benefit from a proper data model.List<Dictionary<List<string>,Dictionary<double,string>>>[]??Customer,Productand so on) and creating classes that represent these conceptual entities with their characteristics and behavior (in the form of properties, methods and events)