유니티
[C#] goto
simstealer
2022. 9. 14. 16:13
goto문은 위치한 레이블로 점프하기위한 문법입니다.
많이 쓰이지 않지만 중첩된 반복문을 뚫고 나올때 사용됩니다.
using static System.Console;
using System.Collections;
namespace Practice01
{
class Class1
{
static void Main()
{
Console.WriteLine("1");
goto JUMP;
Console.WriteLine("2");
Console.WriteLine("3");
Console.WriteLine("4");
JUMP:
Console.WriteLine("5");
}
}
}
위와 같이 1을 출력하고 234를 뛰어 넘고 5를 출력합니다.