Redigera

Dela via


InvalidDataException Constructors

Definition

Initializes a new instance of the InvalidDataException class.

Overloads

InvalidDataException()

Initializes a new instance of the InvalidDataException class.

InvalidDataException(String)

Initializes a new instance of the InvalidDataException class with a specified error message.

InvalidDataException(String, Exception)

Initializes a new instance of the InvalidDataException class with a reference to the inner exception that is the cause of this exception.

Remarks

An InvalidDataException is thrown when invalid data is detected in the data stream, such as in the following situations:

  • A row of data in a delimited text file does not have the expected number of fields.

  • An attempt is made to read a binary file, such as word processing document, that has become corrupted.

  • An attempt is made to read bytes from a decompression stream that has an invalid format.

InvalidDataException()

Source:
InvalidDataException.cs
Source:
InvalidDataException.cs
Source:
InvalidDataException.cs

Initializes a new instance of the InvalidDataException class.

public:
 InvalidDataException();
public InvalidDataException ();
Public Sub New ()

Remarks

This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An invalid argument was specified." This message is localized based on the current system culture.

Applies to

InvalidDataException(String)

Source:
InvalidDataException.cs
Source:
InvalidDataException.cs
Source:
InvalidDataException.cs

Initializes a new instance of the InvalidDataException class with a specified error message.

public:
 InvalidDataException(System::String ^ message);
public InvalidDataException (string message);
public InvalidDataException (string? message);
new System.IO.InvalidDataException : string -> System.IO.InvalidDataException
Public Sub New (message As String)

Parameters

message
String

The error message that explains the reason for the exception.

Remarks

This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An invalid argument was specified." This message is localized based on the current system culture.

Applies to

InvalidDataException(String, Exception)

Source:
InvalidDataException.cs
Source:
InvalidDataException.cs
Source:
InvalidDataException.cs

Initializes a new instance of the InvalidDataException class with a reference to the inner exception that is the cause of this exception.

public:
 InvalidDataException(System::String ^ message, Exception ^ innerException);
public InvalidDataException (string message, Exception innerException);
public InvalidDataException (string? message, Exception? innerException);
new System.IO.InvalidDataException : string * Exception -> System.IO.InvalidDataException
Public Sub New (message As String, innerException As Exception)

Parameters

message
String

The error message that explains the reason for the exception.

innerException
Exception

The exception that is the cause of the current exception. If the innerException parameter is not null, the current exception is raised in a catch block that handles the inner exception.

Remarks

This constructor initializes the Message property of the new instance using the value of the message parameter. The content of the message parameter is intended to be understood by humans. The caller of this constructor is required to ensure that this string has been localized for the current system culture.

An exception that is thrown as a direct result of a previous exception should include a reference to the previous exception in the InnerException property. The InnerException property returns the same value that is passed into the constructor, or null if the InnerException property does not supply the inner exception value to the constructor.

Applies to