我可是抱着100块钱的教材抄给你的 格式<basetype>[] <name>; 其中basetype可以是任何变量类型 数组必须访问之前初始化 初始化有2种 int [] a={5,9,8}; int [] a=new int[3];本回答被提问者和网友采纳
第2个回答 2011-05-30
int a[10] 定义一个为十位的数组,也可以把10变成变量 int a[i]
第3个回答 2011-05-30
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace TestConsole { class Program { static void Main(string[] args) { int n = 5; //一维数组 //创建 int[] a = new int[n]; //初始化 int i; for (i = 0; i < n; i++) a[i] = i; Console.WriteLine("整型一维数组"); foreach (int k in a) Console.Write("{0}\t", k); Console.Write("\n"); //二维数组 char[,] c; //声明 c = new char[n, n]; //申请空间 //初始化 int j; char ch = 'a'; for (i = 0; i < n; i++) for (j = 0; j < n; j++) c[i, j] = Convert.ToChar(Convert.ToInt32(ch)+i+j); Console.WriteLine("字符型二维数组"); for (i = 0; i < n; i++) { for (j = 0; j < n; j++) Console.Write("{0}\t", c[i, j]); Console.WriteLine(); } Console.WriteLine(); } } }