我的代码如下:
for(int i=1; i < 21; i++)
{
list.Add(random.Next(100));
}
for(int i=1; i < 21; i++)
{
Console.Write(list[i] + ", ");
}
Run Code Online (Sandbox Code Playgroud)
不过我刚开了一个Argument out of range exception为 i.
如果我改变的第二个环值i,以0 and 20它完美的作品,怎么回事?