KO CSharp Keyword goto - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki

ะฃะบั€ะฐั—ะฝััŒะบะฐ ยท ะ ัƒััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซ”ไธญๆ–‡ ยท ๆ—ฅๆœฌ่ชž ยท ํ•œ๊ตญ์–ด

C#: goto

ํ•ธ๋“œ๋ถ C# ยท ์‹ค์šฉ ๊ฐ€์ด๋“œ

์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์˜์—ญ์˜ ๋ผ๋ฒจ, ์ผ€์ด์Šค ๋˜๋Š” ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค. ์ฃผ์˜ํ•ด์„œ ์‚ฌ์šฉํ•˜์„ธ์š”. ์ž„์˜์˜ ์ „ํ™˜์œผ๋กœ ์ธํ•ด ์ฝ๊ธฐ๊ฐ€ ์–ด๋ ค์›Œ์ง‘๋‹ˆ๋‹ค.

๊ฐ„๋‹จํ•œ ์˜ˆ์ œ (Example.cs)

์ด ์˜ˆ์ œ๋ฅผ Example.cs๋กœ ๋”ฐ๋กœ ์ €์žฅํ•˜๊ณ  ์ด ํŽ˜์ด์ง€์˜ ๋‹ค๋ฅธ ์˜ˆ์ œ์™€ ๋…๋ฆฝ์ ์œผ๋กœ ์‹คํ–‰ํ•˜์„ธ์š”.

Example.cs:

// PROJECT-EXAMPLE
goto finished;
finished:
System.Console.WriteLine("Done");

๊ฒฐ๊ณผ:

Done

ํ†ต์‚ฌ๋ก 

goto label; / goto case value; / goto default;

์˜ˆ์‹œ 1: ๊ธฐ๋ณธ ํ˜•ํƒœ

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        int attempt = 0;
        retry:
        attempt++;
        Console.WriteLine(attempt);
        if (attempt < 3) goto retry;
    }
}

์˜ˆ 2: ๋˜ ๋‹ค๋ฅธ ์‹ค์ œ ํ˜•์‹

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

public static class Program
{
    public static async Task Main(string[] args)
    {
        int state = 1;
        switch (state) { case 1: Console.WriteLine("Prepare"); goto case 2; case 2: Console.WriteLine("Execute"); break; default: Console.WriteLine("Stop"); break; }
    }
}

๊ณต์‹ ์ถœ์ฒ˜: Microsoft ํ•™์Šต.