Repository navigation
KO CSharp Directive Error
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
지시문이 활성 분기에 속하는 경우 작성자 오류로 컴파일을 중지합니다. 예시는 의도적인 거부 조건을 보여줍니다.
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs:
// PROJECT-EXAMPLE
#define CONFIGURED
#if !CONFIGURED
#error Missing configuration
#endif
System.Console.WriteLine("Configured");이 예제는 컴파일됩니다. CONFIGURED가 정의되어 #error 분기가 비활성화됩니다. 아래의 의도적으로 실패하는 예제는 계속 표시됩니다.
결과:
Configured
#error message이러한 예제는 의도적으로 컴파일되지 않습니다. 원하는 구성을 설정한 후 버그를 제거하거나 비활성 분기로 이동합니다.
상태: 고의적인 컴파일 오류입니다.
#error Missing required configuration
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)
{
Console.WriteLine("Never reached");
}
}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 !CONFIGURED
#error Define CONFIGURED before compiling
#endif
Console.WriteLine("Configured");
}
}공식 출처: Microsoft 학습.
ClassicUO — Bad Newbie & C# Scripts IDE