為什么把for里面的數(shù)字8換成name.Length就會報(bào)錯(cuò)?
using System;
using System.Collections.Generic;
using System.Text;
namespace projGetMaxScore
{
? ? class Program
? ? {
? ? ? ? static void Main(string[] args)
? ? ? ? {
? ? ? ? ? ? string[,] name = { { "吳淞", "89" }, { "錢東宇", "90" }, { "伏晨", "98" }, { " 陳陸", "56" }, { "周蕊", "60" }, { "林日鵬", "91" }, { "何昆", "93" }, { "關(guān)欣", "85" } };
? ? ? ? ? ? int max;
? ? ? ? ? ? int m;
? ? ? ? ? ? m = 0;
? ? ? ? ? ? max = 0;
? ? ? ? ? ? for (int i = 1; i <8; i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if (int.Parse(name[i,1]) > max)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? max = int.Parse(name[i,1]);
? ? ? ? ? ? ? ? ? ? m = i;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? Console.WriteLine("名字{0},分?jǐn)?shù){1}", name[m, 0], name[m, 1]);
? ? ? ? }
? ? }
}
2021-12-18
??
name.Length是這個(gè)二維數(shù)組的長度,它的值是16.
正確答案? ? for (int i = 1; i < name.GetLength(0); i++)