IndexOutOfRangeException IndexOutOfRangeException IndexOutOfRangeException IndexOutOfRangeException Constructors

定義

多載

IndexOutOfRangeException() IndexOutOfRangeException() IndexOutOfRangeException()

初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class.

IndexOutOfRangeException(String) IndexOutOfRangeException(String) IndexOutOfRangeException(String) IndexOutOfRangeException(String)

使用指定的錯誤訊息,初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class with a specified error message.

IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class with a specified error message and a reference to the inner exception that is the cause of this exception.

IndexOutOfRangeException() IndexOutOfRangeException() IndexOutOfRangeException()

初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class.

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

備註

此函式會Message將新實例的屬性初始化為系統提供的訊息, 以描述錯誤, 例如「陣列索引超出範圍」。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "An array index is out of range." 此訊息會考量目前的系統文化特性。This message takes into account the current system culture.

下表顯示 IndexOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of IndexOutOfRangeException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 當地語系化的錯誤訊息字串。The localized error message string.

IndexOutOfRangeException(String) IndexOutOfRangeException(String) IndexOutOfRangeException(String) IndexOutOfRangeException(String)

使用指定的錯誤訊息,初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class with a specified error message.

public:
 IndexOutOfRangeException(System::String ^ message);
public IndexOutOfRangeException (string message);
new IndexOutOfRangeException : string -> IndexOutOfRangeException
Public Sub New (message As String)

參數

message
String String String String

描述錯誤的訊息。The message that describes the error.

備註

此函式會Exception.Message message使用參數, 初始化新例外狀況的屬性。This constructor initializes the Exception.Message property of the new exception using the message parameter. message 的內容必須能讓人了解。The content of message 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.

下表顯示 IndexOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of IndexOutOfRangeException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.

IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception) IndexOutOfRangeException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 IndexOutOfRangeException 類別的新執行個體。Initializes a new instance of the IndexOutOfRangeException class with a specified error message and a reference to the inner exception that is the cause of this exception.

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

參數

message
String String String String

解釋例外狀況原因的錯誤訊息。The error message that explains the reason for the exception.

innerException
Exception Exception Exception Exception

做為目前例外狀況發生原因的例外狀況。The exception that is the cause of the current exception. 如果 innerException 參數不是 Null 參考 (在 Visual Basic 中為 Nothing),則會在處理內部例外的 catch 區塊中引發目前的例外狀況。If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.

備註

被擲回以做為前一個例外狀況直接結果的例外狀況,應該在 InnerException 屬性中包含對前一個例外狀況的參考。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. InnerException 屬性會傳回與傳入建構函式中相同的值;如果 Nothing 屬性不提供內部例外值給建構函式,則傳回 null 參考 (在 Visual Basic 中為 InnerException)。The InnerException property returns the same value that is passed into the constructor, or a null reference (Nothing in Visual Basic) if the InnerException property does not supply the inner exception value to the constructor.

下表顯示 IndexOutOfRangeException 執行個體的初始屬性值。The following table shows the initial property values for an instance of IndexOutOfRangeException.

屬性Property Value
InnerException 內部例外狀況參考。The inner exception reference.
Message 錯誤訊息字串。The error message string.
另請參閱

適用於