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 ํ์ต.