如何在C#中定义数组?
在C#中定义数组-
int[] runs = new int[10];
现在让我们在同一行中初始化数组-
int[] runs = new int[5] {99, 92, 95};
以下是显示如何声明,初始化和显示数组的示例-
示例
using System; namespace Program { class Demo { static void Main(string[] args) { int[] runs = new int[3] {149, 123, 257}; int j; for (j = 0; j < 3; j++ ) { Console.WriteLine("Score of Cricketer[{0}] = {1}", j, runs[j]); } Console.ReadKey(); } } }