我是新來的請幫助我。代碼正在運行,但之後,compailer不打印任何內容,並給出IndexOutOfRangeException的錯誤。我收到錯誤IndexOutOfRangeException
class Program
{
static void Main(string[] args)
{
string brd = board();
string[] sub = subjects();
Console.WriteLine(brd);
Console.WriteLine(sub);
Console.ReadLine();
}
public static string board()
{
Console.WriteLine("Please Enter Board Name ");
string Board = Console.ReadLine();
return Board;
}
public static string[] subjects()
{
Console.WriteLine("Please Enter How many Subject Do you Want to input");
int limit = System.Convert.ToInt32(Console.ReadLine());
string[] Subjects = new string[limit];
string[] index = new string[limit];
for (limit = 1; limit <= index.Length; limit++)
{
Console.WriteLine("Please Enter Subject Name " + limit);
Subjects[limit] = Console.ReadLine();
}
return Subjects;
}
}
陣列中NET開始,你可以找到這個信息無處不在 – Steve
'的(限= 1;限制<= index.Length;限制++)'應該是'爲( limit = 0; limit
Mairaj