次の方法で共有


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

更新 : 2007 年 11 月

#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
    }
}

DEBUG is not defined

参照

概念

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

参照

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

その他の技術情報

C# リファレンス