ErrorEventArgs(Exception) Constructor
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Initializes a new instance of the ErrorEventArgs class.
public:
ErrorEventArgs(Exception ^ exception);
public ErrorEventArgs (Exception exception);
new System.IO.ErrorEventArgs : Exception -> System.IO.ErrorEventArgs
Public Sub New (exception As Exception)
Parameters
Examples
The following example creates a new instance of ErrorEventArgs and initializes it with an Exception. Then the example calls GetException to retrieve the Exception and display the error message. There is no form associated with this code.
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
Applies to
Συνεργαστείτε μαζί μας στο GitHub
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.