AmbiguousMatchException コンストラクタ ()とは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > AmbiguousMatchException コンストラクタ ()の意味・解説 

AmbiguousMatchException コンストラクタ ()

空のメッセージ文字列使用し主要原因となる例外null 参照 (Visual Basic では Nothing) に設定して、AmbiguousMatchException クラス新しインスタンス初期化します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim instance As New AmbiguousMatchException
public AmbiguousMatchException ()
public:
AmbiguousMatchException ()
public AmbiguousMatchException ()
public function AmbiguousMatchException ()
解説解説

AmbiguousMatchExceptionException から継承します。このコンストラクタは、次の表に示すように、Exception オブジェクトプロパティ設定します

プロパティ

InnerException

null 参照 (Visual Basic では Nothing)

Message

空の文字列 ("")。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AmbiguousMatchException クラス
AmbiguousMatchException メンバ
System.Reflection 名前空間
Exception
SystemException

AmbiguousMatchException コンストラクタ (String)

メッセージ文字列セット特定のメッセージに、主要原因となる例外null 参照 (Visual Basic では Nothing) に設定して、AmbiguousMatchException クラス新しインスタンス初期化します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Dim message As String

Dim instance As New AmbiguousMatchException(message)
public AmbiguousMatchException (
    string message
)
public:
AmbiguousMatchException (
    String^ message
)
public AmbiguousMatchException (
    String message
)
public function AmbiguousMatchException (
    message : String
)

パラメータ

message

この例外スローされた原因を示す文字列。

解説解説

AmbiguousMatchExceptionException から継承します。このコンストラクタは、次の表に示すように、Exception オブジェクトプロパティ設定します

プロパティ

InnerException

null 参照 (Visual Basic では Nothing)

Message

message 文字列

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AmbiguousMatchException クラス
AmbiguousMatchException メンバ
System.Reflection 名前空間

AmbiguousMatchException コンストラクタ

AmbiguousMatchException クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

AmbiguousMatchException クラス
AmbiguousMatchException メンバ
System.Reflection 名前空間
Exception
SystemException

AmbiguousMatchException コンストラクタ (String, Exception)

指定したエラー メッセージと、この例外原因である内部例外への参照使用して、AmbiguousMatchException クラス新しインスタンス初期化します。

名前空間: System.Reflection
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

解説解説

前の例外直接結果としてスローされる例外については、InnerException プロパティに、前の例外への参照格納されます。InnerException プロパティは、コンストラクタ渡されたものと同じ値を返しますInnerException プロパティによって内部例外値がコンストラクタ渡されなかった場合は、null 参照 (Visual Basic では Nothing) を返します

AmbiguousMatchExceptionインスタンス初期プロパティ値を次の表に示します

使用例使用例

Mymethod という名前の 2 つクラス次の例で示します一方クラス整数をとり、もう一方クラスは文字列をとります整数Mymethod渡されると、最初クラス使用されます。文字列渡され場合は、2 番目のクラス使用されます。どちらの Mymethod使用する判断できない場合は、AmbiguousMatchExceptionスローさます。

Class Myambiguous
    
    'The first overload is typed to an Int32
    Overloads Public Shared
 Sub Mymethod(number As Int32)
        Console.Write(ControlChars.Cr + "{0}", "I
 am from Int32 method")
    End Sub 'Mymethod
    
    
    'The second overload is typed to a string
    Overloads Public Shared
 Sub Mymethod(alpha As String)
        Console.Write(ControlChars.Cr + "{0}", "I
 am from a string.")
    End Sub 'Mymethod
    
    
    Public Shared Sub Main()
        Try
            'The following does not cause as exception
            Mymethod(2) ' goes to Mymethod (Int32)
            Mymethod("3") ' goes to Mymethod
 (string)
            Dim Mytype As Type = Type.GetType("Myambiguous")
            
            Dim Mymethodinfo32 As MethodInfo
 = Mytype.GetMethod("Mymethod", New
 Type() {GetType(Int32)})
            Dim Mymethodinfostr As MethodInfo
 = Mytype.GetMethod("Mymethod", New
 Type() {GetType(System.String)})
            
            'Invoke a method, utilizing a Int32 integer
            Mymethodinfo32.Invoke(Nothing, New
 Object() {2})
            
            'Invoke the method utilizing a string
            Mymethodinfostr.Invoke(Nothing, New
 Object() {"1"})
            
            'The following line causes an ambiguious exception
            Dim Mymethodinfo As MethodInfo
 = Mytype.GetMethod("Mymethod")
        ' end of try block
        Catch theException As System.Reflection.AmbiguousMatchException
            Console.Write(ControlChars.Cr & "AmbiguousMatchException
 message - {0}", theException.Message)
        Catch
        End Try
        Return
    End Sub 'Main
End Class 'Myambiguous

'This code produces the following output:
'I am from Int32 method
'I am from a string.
'I am from Int32 method
'I am from a string.
'AmbiguousMatchException message - Ambiguous match found.
class Myambiguous {
    //The first overload is typed to an Int32
    public static void Mymethod
 (Int32 number){
       Console.Write("\n{0}", "I am from Int32 method");
    }

    //The second overload is typed to a string
    public static void Mymethod
 (string alpha) {
       Console.Write("\n{0}", "I am from a string.");
    }
    
    public static void Main()
 {
        try {
            //The following does not cause as exception
            Mymethod (2);  // goes to Mymethod (Int32)
            Mymethod ("3");   // goes to Mymethod (string)

            Type Mytype = Type.GetType("Myambiguous");

            MethodInfo Mymethodinfo32 = Mytype.GetMethod("Mymethod", new
 Type[]{typeof(Int32)});
            MethodInfo Mymethodinfostr = Mytype.GetMethod("Mymethod", new
 Type[]{typeof(System.String)});

            //Invoke a method, utilizing a Int32 integer
            Mymethodinfo32.Invoke(null, new
 Object[]{2});

            //Invoke the method utilizing a string
            Mymethodinfostr.Invoke(null, new
 Object[]{"1"});

            //The following line causes an ambiguious exception
            MethodInfo Mymethodinfo = Mytype.GetMethod("Mymethod");
        }  // end of try block
  
        catch(System.Reflection.AmbiguousMatchException theException)
 {
            Console.Write("\nAmbiguousMatchException message - {0}", theException.Message);
        }
        catch {
            Console.Write("\nError thrown");
        }
        return;
    }
}
 
 //This code produces the following output:
 //I am from Int32 method
 //I am from a string.
 //I am from Int32 method
 //I am from a string.
 //AmbiguousMatchException message - Ambiguous match found.
ref class Myambiguous
{
public:

   //The first overload is typed to an Int32
   static void Mymethod( Int32 number )
   {
      Console::Write( "\nI am from Int32 method" );
   }

   //The second overload is typed to a String*
   static void Mymethod( String^ alpha )
   {
      Console::Write( "\nI am from a String*." );
   }

   static void main()
   {
      try
      {
         //The following does not cause as exception
         Mymethod( 2 ); // goes to Mymethod (Int32)
         Mymethod( "3" ); // goes to Mymethod (String*)
         Type^ Mytype = Type::GetType( "Myambiguous" );
         array<Type^>^temp0 = {Int32::typeid};
         MethodInfo^ Mymethodinfo32 = Mytype->GetMethod( "Mymethod",
 temp0 );
         array<Type^>^temp1 = {System::String::typeid};
         MethodInfo^ Mymethodinfostr = Mytype->GetMethod( "Mymethod",
 temp1 );

         //Invoke a method, utilizing a Int32 integer
         array<Object^>^temp2 = {2};
         Mymethodinfo32->Invoke( nullptr, temp2 );

         //Invoke the method utilizing a String*
         array<Object^>^temp3 = {"1"};
         Mymethodinfostr->Invoke( nullptr, temp3 );

         //The following line causes an ambiguous exception
         MethodInfo^ Mymethodinfo = Mytype->GetMethod( "Mymethod" );
      }
      catch ( System::Reflection::AmbiguousMatchException^ theException
 ) 
      {
         Console::Write( "\nAmbiguousMatchException message - {0}", theException->Message
 );
      }
      catch ( Exception^ ) 
      {
         Console::Write( "\nError thrown" );
      }

      return;
   }
};

int main()
{
   Myambiguous::main();
}

//This code produces the following output:
//I am from Int32 method
//I am from a String*.
//I am from Int32 method
//I am from a String*.
//AmbiguousMatchException message - Ambiguous match found.
class MyAmbiguous
{
    //The first overload is typed to an Int32
    public static void MyMethod(Integer
 number)
    {
        Console.Write("\n{0}", "I am from Int32 method");
    } //MyMethod

    //The second overload is typed to a string
    public static void MyMethod(String
 alpha)
    {
        Console.Write("\n{0}", "I am from a string.");
    } //MyMethod

    public static void main(String[]
 args)
    {
        try {
            //The following does not cause as exception
            MyMethod(new Integer(2)); // goes to
 MyMethod (Int32)
            MyMethod("3"); // goes to MyMethod (string)

            Type myType = Type.GetType("MyAmbiguous");
            MethodInfo myMethodInfo32 = myType.GetMethod("MyMethod", 
                new Type[] { Integer.class.ToType()
 });
            MethodInfo myMethodInfoStr = myType.GetMethod("MyMethod", 
                new Type[] { String.class.ToType()
 });

            //Invoke a method, utilizing a Int32 integer
            myMethodInfo32.Invoke(null, new
 Object[] { new Integer(2) });

            //Invoke the method utilizing a string
            myMethodInfoStr.Invoke(null, new
 Object[] { "1" });

            //The following line causes an ambiguious exception
            MethodInfo myMethodInfo = myType.GetMethod("MyMethod");
        } // end of try block
        catch (System.Reflection.AmbiguousMatchException theException)
 {
            Console.Write("\nAmbiguousMatchException message - {0}", 
                theException.get_Message());
        }
        catch (System.Exception exp) {
            Console.Write("\nError thrown");
        }
        return;
    } //main
} //MyAmbiguous

//This code produces the following output:
//I am from Int32 method
//I am from a string.
//I am from Int32 method
//I am from a string.
//AmbiguousMatchException message - Ambiguous match found.
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「AmbiguousMatchException コンストラクタ ()」の関連用語

AmbiguousMatchException コンストラクタ ()のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



AmbiguousMatchException コンストラクタ ()のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS