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