WarningException 類別

定義

指定一個例外,該例外以警告而非錯誤處理。

public ref class WarningException : SystemException
public class WarningException : SystemException
[System.Serializable]
public class WarningException : SystemException
type WarningException = class
    inherit SystemException
[<System.Serializable>]
type WarningException = class
    inherit SystemException
Public Class WarningException
Inherits SystemException
繼承
WarningException
屬性

範例

以下程式碼範例說明如何捕捉警告並解讀其警告訊息。

WarningException^ myEx = gcnew WarningException( "This is a warning" );
Console::WriteLine( myEx->Message );
Console::WriteLine( myEx->ToString() );
WarningException myEx = new("This is a warning");
Console.WriteLine(myEx.Message);
Console.WriteLine(myEx.ToString());
Dim myEx As New WarningException("This is a warning")
Console.WriteLine(myEx.Message)
Console.WriteLine(myEx.ToString())

備註

若未發現此例外,則會以警告訊息形式呈現給使用者。 在 WarningException 建構子中,你可以指定說明檔案和說明主題,以便在使用者要求更多資訊時顯示。

建構函式

名稱 Description
WarningException()

初始化 WarningException 類別的新執行個體。

WarningException(SerializationInfo, StreamingContext)
已淘汰.

利用指定的序列化資料與上下文初始化該類別的新 WarningException 實例。

WarningException(String, Exception)

初始化一個帶有指定詳細描述與例外的新類別實例 WarningException

WarningException(String, String, String)

初始化類別的新實例 WarningException ,包含指定的訊息,並可存取指定的說明檔案與主題。

WarningException(String, String)

初始化該類別的新實例 WarningException ,包含指定的訊息,並取得指定的說明檔案。

WarningException(String)

初始化一個新的類別實例 WarningException ,包含指定的訊息且沒有說明檔案。

屬性

名稱 Description
Data

取得一組鍵值對,提供關於例外的額外使用者定義資訊。

(繼承來源 Exception)
HelpLink

取得或設定與此例外相關的說明檔案連結。

(繼承來源 Exception)
HelpTopic

警告時會被「幫助」主題連結。

HelpUrl

會取得與警告相關的說明檔案。

HResult

取得或設定 HRESULT,一個編碼的數值,指派給特定例外。

(繼承來源 Exception)
InnerException

會取得 Exception 造成目前例外的實例。

(繼承來源 Exception)
Message

取得描述目前例外狀況的訊息。

(繼承來源 Exception)
Source

取得或設定造成錯誤之應用程式或物件的名稱。

(繼承來源 Exception)
StackTrace

會取得呼叫堆疊上即時框架的字串表示。

(繼承來源 Exception)
TargetSite

會取得拋出當前例外的方法。

(繼承來源 Exception)

方法

名稱 Description
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetBaseException()

當在派生類別中被覆寫時,回傳 Exception 是一個或多個後續例外的根因。

(繼承來源 Exception)
GetHashCode()

做為預設哈希函式。

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)
已淘汰.

設定 SerializationInfo 參數名稱及額外例外資訊。

GetObjectData(SerializationInfo, StreamingContext)
已淘汰.

在衍生類別中覆寫時,使用例外狀況的相關信息來設定 SerializationInfo

(繼承來源 Exception)
GetType()

取得目前實例的執行時型態。

(繼承來源 Exception)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
ToString()

建立並回傳當前例外的字串表示。

(繼承來源 Exception)

事件

名稱 Description
SerializeObjectState
已淘汰.

當例外被序列化以建立包含該例外序列化資料的例外狀態物件時,會發生這種情況。

(繼承來源 Exception)

適用於