How do I add new to items to this Array?
public static string[,] myArray = new string[,] { { "1", "1a" }, { "2", "2a" } };
public Form1()
{
InitializeComponent();
myArray.add("3", "3a"); // error
for (int i = 0; i < myArray.GetLength(0); i++)
{
Console.WriteLine(myArray[i, 0] +", "+ myArray[i, 1]);
}
}
thank you.
Arrays are fixed once you’ve created them. Use a
Listwhen you want to add items. Even though you don’t provide dimensions, these are inferred from the declaration and cannot be changed later on.