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

#warning を使用すると、コードの特定の位置でレベル 1 警告を表示できます。 次に例を示します。

#warning Deprecated code in this method.

解説

#warning は、一般に、条件付きディレクティブ内で使用します。 また、#error (C# リファレンス) でユーザー定義のエラーを生成することもできます。

使用例

// preprocessor_warning.cs
// CS1030 expected
#define DEBUG
class MainClass 
{
    static void Main() 
    {
#if DEBUG
#warning DEBUG is defined
#endif
    }
}

参照

参照

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

概念

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

その他の技術情報

C# リファレンス