static void Main(string[] args)
{
int[] age = ;//声明并初始化长度为4的整形数组
//为数组元素赋值
age[0 ] = 18;
age[1 ] = 20;
age[2 ] = 23;
age[3 ] = 17;
Console.WriteLine("四名同学的年龄是:{0}、{1}、{2}、{3}", age[0 ],age[1 ],age[2 ],age[ 3]);
}
}
你并没有对整型数组age[]进行声明。
using System; using System.Collections.Generic; using System.Text; namespace Test { class Program { static void Main(string[] args) { int[] age = new int[4];//声明并初始化长度为4的整形数组 //为数组元素赋值 age[0] = 18; age[1] = 20; age[2] = 23; age[3] = 17; Console.WriteLine("四名同学的年龄是:{0}、{1}、{2}、{3}", age[0],age[1],age[2],age[3]); } } }
你的第11行没有完成