指定したエラー メッセージと、この例外の原因である内部例外への参照を使用して、ArrayTypeMismatchException クラスの新しいインスタンスを初期化します。
名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文
'宣言
Public Sub New ( _
message As String, _
innerException As Exception _
)
'使用
Dim message As String
Dim innerException As Exception
Dim instance As New ArrayTypeMismatchException(message, innerException)
public ArrayTypeMismatchException (
string message,
Exception innerException
)
public:
ArrayTypeMismatchException (
String^ message,
Exception^ innerException
)
public ArrayTypeMismatchException (
String message,
Exception innerException
)
public function ArrayTypeMismatchException (
message : String,
innerException : Exception
)
パラメータ
- message
例外の原因を説明するエラー メッセージ。
- innerException
現在の例外の原因である例外。innerException パラメータが null 参照でない場合は、内部例外を処理する catch ブロックで現在の例外が発生します。
解説
前の例外の直接の結果としてスローされる例外については、InnerException プロパティに、前の例外への参照が格納されます。InnerException プロパティは、コンストラクタに渡されたものと同じ値を返します。InnerException プロパティによって内部例外値がコンストラクタに渡されなかった場合は、null 参照 (Visual Basic の場合は Nothing) を返します。
ArrayTypeMismatchException のインスタンスの初期プロパティ値を次の表に示します。
プロパティ |
値 |
---|---|
InnerException |
内部例外参照。 |
エラー メッセージ文字列。 |
使用例
Imports System
Public Class ArrayTypeMisMatchConst
Public Sub CopyArray(myArray As Array, myArray1 As Array)
Try
' Copies the value of one array into another array.
myArray.SetValue(myArray1.GetValue(0), 0)
myArray.SetValue(myArray1.GetValue(1), 1)
Catch e As Exception
' Throw an exception of type 'ArrayTypeMismatchException' with a message and innerexception.
Throw New ArrayTypeMismatchException("The Source and destination arrays are of not same type", e)
End Try
End Sub 'CopyArray
Shared Sub Main()
Try
Dim myStringArray(2) As String
myStringArray.SetValue("Jones", 0)
myStringArray.SetValue("John", 1)
Dim myIntArray(2) As Integer
Dim myArrayType As New ArrayTypeMisMatchConst()
myArrayType.CopyArray(myStringArray, myIntArray)
Catch e As ArrayTypeMismatchException
Console.WriteLine("The Exception Message is : " + e.Message)
Console.WriteLine("The Inner exception is :" + e.InnerException.ToString())
End Try
End Sub 'Main
End Class 'ArrayTypeMisMatchConst
using System;
public class ArrayTypeMisMatchConst
{
public void CopyArray(Array myArray,Array myArray1)
{
try
{
// Copies the value of one array into another array.
myArray.SetValue(myArray1.GetValue(0),0);
myArray.SetValue(myArray1.GetValue(1),1);
}
catch(Exception e)
{
// Throw an exception of with a message and innerexception.
throw new ArrayTypeMismatchException("The Source and destination arrays are of not same type.", e);
}
}
static void Main()
{
try
{
string[] myStringArray = new string[2];
myStringArray.SetValue("Jones",0);
myStringArray.SetValue("John",1);
int[] myIntArray = new int[2];
ArrayTypeMisMatchConst myArrayType = new ArrayTypeMisMatchConst();
myArrayType.CopyArray(myStringArray,myIntArray);
}
catch(ArrayTypeMismatchException e)
{
Console.WriteLine("The Exception Message is : "+e.Message);
Console.WriteLine("The Inner exception is :"+e.InnerException);
}
}
}
using namespace System;
public ref class ArrayTypeMisMatchConst
{
public:
void CopyArray( Array^ myArray, Array^ myArray1 )
{
try
{
// Copies the value of one array into another array.
myArray->SetValue( myArray1->GetValue( 0 ), 0 );
myArray->SetValue( myArray1->GetValue( 1 ), 1 );
}
catch ( Exception^ e )
{
// Throw an exception of with a message and innerexception.
throw gcnew ArrayTypeMismatchException( "The Source and destination arrays are of not same type.",e );
}
}
};
int main()
{
try
{
array<String^>^myStringArray = gcnew array<String^>(2);
myStringArray->SetValue( "Jones", 0 );
myStringArray->SetValue( "John", 1 );
array<Int32>^myIntArray = gcnew array<Int32>(2);
ArrayTypeMisMatchConst^ myArrayType = gcnew ArrayTypeMisMatchConst;
myArrayType->CopyArray( myStringArray, myIntArray );
}
catch ( ArrayTypeMismatchException^ e )
{
Console::WriteLine( "The Exception Message is : {0}", e->Message );
Console::WriteLine( "The Inner exception is : {0}", e->InnerException );
}
}
import System.*;
public class ArrayTypeMisMatchConst
{
public void CopyArray(Array myArray, Array myArray1)
{
try {
// Copies the value of one array into another array.
myArray.SetValue(myArray1.GetValue(0), 0);
myArray.SetValue(myArray1.GetValue(1), 1);
}
catch (System.Exception e) {
// Throw an exception of with a message and innerexception.
throw new ArrayTypeMismatchException("The Source and destination"
+ " arrays are of not same type.", e);
}
} //CopyArray
public static void main(String[] args)
{
try {
String myStringArray[] = new String[2];
myStringArray.SetValue("Jones", 0);
myStringArray.SetValue("John", 1);
int myIntArray[] = new int[2];
ArrayTypeMisMatchConst myArrayType = new ArrayTypeMisMatchConst();
myArrayType.CopyArray(myStringArray, myIntArray);
}
catch (ArrayTypeMismatchException e) {
Console.WriteLine("The Exception Message is : " + e.get_Message());
Console.WriteLine("The Inner exception is :" + e.
get_InnerException());
}
} //main
} //ArrayTypeMisMatchConst
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
.NET Compact Framework
サポート対象 : 2.0、1.0
参照
関連項目
ArrayTypeMismatchException クラス
ArrayTypeMismatchException メンバ
System 名前空間
Exception