ErrorEventArgs(Exception) Konstruktor
Definicja
Ważne
Niektóre informacje odnoszą się do produktu w wersji wstępnej, który może zostać znacząco zmodyfikowany przed wydaniem. Firma Microsoft nie udziela żadnych gwarancji, jawnych lub domniemanych, w odniesieniu do informacji podanych w tym miejscu.
Inicjuje nowe wystąpienie klasy ErrorEventArgs.
public:
ErrorEventArgs(Exception ^ exception);
public ErrorEventArgs(Exception exception);
new System.IO.ErrorEventArgs : Exception -> System.IO.ErrorEventArgs
Public Sub New (exception As Exception)
Parametry
Przykłady
Poniższy przykład tworzy nowe wystąpienie ErrorEventArgs klasy i inicjuje je za pomocą elementu Exception. Następnie przykładowe wywołania GetException w celu pobrania Exception i wyświetlenia komunikatu o błędzie. Nie ma formularza skojarzonego z tym kodem.
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