报错问题?
System.IndexOutOfRangeException:“Index was outside the bounds of the array.”请问这个报错是什么问题呀
代码没有问题
static void Main(string[] args)
{
int[] num = new int[] { 3, 34, 43, 2, 11, 19, 30, 55, 20 };
bool hasit = false;
foreach(int i in num)
{
if (num[i] % 7 == 0)
{
hasit = true;
break;
}
}
if (hasit)
{
Console.Write("有七的倍数");
}
else
{
Console.Write("没有七的倍数");
}
}
}