static void Main(string[] args)
{
int[] arrInt1 = new int[3] { 1, 2, 3 };
int[] arrInt2 = new int[] { 4, 5, 6 };
int[] arrInt3 = { 7, 8, 9 };
for (int i = 0; i < arrInt1.Length; i++)
{
Console.Write(arrInt1[i] + " ");
}
Console.WriteLine("\n****************************");
foreach (int item in arrInt2)
{
Console.Write(item + " ");
}
Console.WriteLine("\n****************************");
int a = arrInt3[1];
Console.WriteLine(a);
Console.ReadKey();
}
数组:存储相同数据类型的数据。
int[] arrInt1 = new int[3] { 1, 2, 3 };
确定数组元素的数量。
int[] arrInt2 = new int[] { 4, 5, 6 };
int[] arrInt3 = { 7, 8, 9 };
根据元素个数自动分配空间。