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

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

C#: enum

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

๋ช…๋ช…๋œ ์ •์ˆ˜ ๊ฐ’์„ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. ํ”Œ๋ž˜๊ทธ๋Š” ๋…๋ฆฝ์ ์ธ ๋น„ํŠธ๋ฅผ ์„ค๋ช…ํ•˜์ง€๋งŒ ๊ฐ’์ด ์œ ํšจํ•œ์ง€ ์ž๋™์œผ๋กœ ํ™•์ธํ•˜์ง€๋Š” ์•Š์Šต๋‹ˆ๋‹ค.

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

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

Example.cs:

// PROJECT-EXAMPLE
State state = State.Ready;
System.Console.WriteLine(state);
enum State { Idle, Ready }

๊ฒฐ๊ณผ:

Ready

ํ†ต์‚ฌ๋ก 

enum State { Idle, Active }

์˜ˆ์‹œ 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)
    {
        State state = State.Active;
        Console.WriteLine($"{state}:{(int)state}");
    }
}
public enum State : byte { Idle = 0, Active = 1 }

์˜ˆ 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)
    {
        Options options = Options.Read | Options.Write;
        Console.WriteLine(options.HasFlag(Options.Read));
    }
}
[Flags] public enum Options { None = 0, Read = 1, Write = 2 }

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