I have a small problem, I hope and you can support me;
The problem is that I want to make a 2-dimensional arrangement to make a table, something like this:
string[][] dat = new string[][]
{
new string[] {"Tienda" ,"Existencias"},
new string[] {"Argentina","1"},
new string[] {"México","5"},
new string[] {"Brazil","9"},
new string[] {"Canada","2"}
};
As you can see, there are 2 columns and several rows, the columns are always going to be 2 but the rows may vary.
To be moving the array indexes and and filling them with for
,
this is the code that I have and try but only the last element that gives true in if
is saved;
Store[] tienda = p_item;
for (int c = 0; c < tienda.Length; c++)
{
if (tienda[c].stockOnHand > 0)
{
string[][] dat = new string[][]
{
new string[] {tienda[c].storeName ,tienda[c].stockOnHand.ToString()}
};
v_dataTable = dat;
}
else
{
}
}
Try putting a variable that was increasing, but it shows me an error: "Error 1 A constant value is expected"
string[][] dat = new string[][]
{
new string[numero] {tienda[c].storeName ,tienda[c].stockOnHand.ToString()}
};
numero++;
Is there any way to do something like this?
String[][] dat = new String[][];
dat[c][1]={"tienda[c].storeName ,tienda[c].stockOnHand.ToString()"};
To fill the positions according to the position of the arrangement and to make the table.
Do you have any other idea of how to fill that arrangement?