昨天写了个C#乘法表,今天使用一下Goto,C#也可以用Goto.
for(int a=1;a<=9;a++)
{
for(int b=1;b<=a;b++)
{
goto outfor;
Console.Write("{0}*{1}={2}",a,b,a*b);
}
Console.WriteLine();
}
Console.ReadLine();
outfor:
Console.Write("outfor");
这样就不需要使用break,一个一个得跳了。呵呵。{
for(int b=1;b<=a;b++)
{
goto outfor;
Console.Write("{0}*{1}={2}",a,b,a*b);
}
Console.WriteLine();
}
Console.ReadLine();
outfor:
Console.Write("outfor");