共用方式為


#warning (C# 參考)

#warning 讓您可以從程式碼中的特定位置產生第一級警告。 例如:

#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# 參考