KO CSharp Directive Conditional - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
์กฐ๊ฑด๋ถ ์ปดํ์ผ
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
๋ฐํ์ ๋ณ์๊ฐ ์๋ ๊ธฐํธ๋ก ์ปดํ์ผํ๋ ๋์ ์์ค ์ฝ๋์ ์ผ๋ถ๋ฅผ ์ ํํฉ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
#define REPORT
#if REPORT
System.Console.WriteLine("Enabled");
#else
System.Console.WriteLine("Disabled");
#endif
๊ฒฐ๊ณผ:
Enabled
ํต์ฌ๋ก
#if FEATURE
// code
#elif OTHER
// other code
#else
// fallback
#endif
์์ 1
#define FEATURE
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)
{
#if FEATURE
Console.WriteLine("Feature enabled");
#else
Console.WriteLine("Fallback");
#endif
}
}
์์ 2
#define SECOND
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)
{
#if FIRST
Console.WriteLine("First");
#elif SECOND
Console.WriteLine("Second");
#else
Console.WriteLine("Neither");
#endif
}
}
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.