利用for循环和foreach循环为什么结果不同 求大神帮忙
int[] num = new int[] { 3, 34, 43, 2, 11, 19, 30, 55, 20 };
bool has = false;
for(int x =0;x<num.Length ; x++)
//foreach (var x in num)
{
if (x % 7 == 0)
{
has = true;
break;
}
}
if (has)
{
Console.WriteLine("有七的倍数");
}
else
{
Console.WriteLine("没有七的倍数");
}