ErrorEventArgs(Exception) 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 ErrorEventArgs 類別的新執行個體。
public:
ErrorEventArgs(Exception ^ exception);
public ErrorEventArgs (Exception exception);
new System.IO.ErrorEventArgs : Exception -> System.IO.ErrorEventArgs
Public Sub New (exception As Exception)
參數
範例
下列範例會建立 的新實例 ErrorEventArgs ,並使用 初始化它 Exception。 然後,範例會呼叫 GetException 來擷取 Exception 並顯示錯誤訊息。 沒有與此程式代碼相關聯的表單。
int main()
{
//Creates an exception with an error message.
Exception^ myException = gcnew Exception( "This is an exception test" );
//Creates an ErrorEventArgs with the exception.
ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException );
//Extracts the exception from the ErrorEventArgs and display it.
Exception^ myReturnedException = myErrorEventArgs->GetException();
MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) );
}
public static void Main(string[] args) {
//Creates an exception with an error message.
Exception myException= new Exception("This is an exception test");
//Creates an ErrorEventArgs with the exception.
ErrorEventArgs myErrorEventArgs = new ErrorEventArgs(myException);
//Extracts the exception from the ErrorEventArgs and display it.
Exception myReturnedException = myErrorEventArgs.GetException();
MessageBox.Show("The returned exception is: " + myReturnedException.Message);
}
Public Shared Sub Main()
'Creates an exception with an error message.
Dim myException As New Exception("This is an exception test")
'Creates an ErrorEventArgs with the exception.
Dim myErrorEventArgs As New ErrorEventArgs(myException)
'Extracts the exception from the ErrorEventArgs and display it.
Dim myReturnedException As Exception = myErrorEventArgs.GetException()
MessageBox.Show("The returned exception is: " _
+ myReturnedException.Message)
End Sub