次の方法で共有


#undef (C# リファレンス)

#undef を使用すると、シンボルを未定義状態にできます。たとえば、未定義状態のシンボルを #iff ディレクティブで式として使用すると、その式は false と評価されます。

シンボルは、#define ディレクティブまたは /define コンパイラ オプションで定義できます。#undef ディレクティブをファイルに記述する場合は、ディレクティブやそれ以外のステートメントよりも前に記述する必要があります。

使用例

// preprocessor_undef.cs
// compile with: /d:DEBUG
#undef DEBUG
using System;
class MyClass 
{
    static void Main() 
    {
#if DEBUG
        Console.WriteLine("DEBUG is defined");
#else
        Console.WriteLine("DEBUG is not defined");
#endif
    }
}
  

参照

関連項目

C# プリプロセッサ ディレクティブ

概念

C# プログラミング ガイド

その他の技術情報

C# リファレンス