//最后面都有源码的下载地址。
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks;
namespace _3数组的使用方法 { class Program { static void Main(string[] args) { //数组使用的基本步骤 //[1]声明数组 int[] scores; //[2]分配空间 scores = new int[5]; //[3]赋值 scores[1] = 4; //[4]处理数据 scores[1] = scores[1] + 7; scores[2] = scores[2] + 3;
//声明数组的几种方法 int[] score1 = new int[] { 1, 3, 7 }; string[] score2 = new string[] { "", "", "" }; float[] score3 = { 12, 3, 7 }; //数组的长度 int corelength = score3.Length; //使用for循环读取数组的元素 float sum1 = 0; for (int i = 0; i < score3.Length; i++) { sum1