Type.GetInterfaceとは? わかりやすく解説

Type.GetInterface メソッド (String)

指定した名前のインターフェイスを検索します。

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

例外例外
例外の種類条件

ArgumentNullException

name が null 参照 (Visual Basic では Nothing) です。

AmbiguousMatchException

現在の Type は、別の型引数で同じジェネリック インターフェイスを実装する型を表します。

解説解説
使用例使用例
   Public Shared Sub Main()
      Dim hashtableObj As New
 Hashtable()
      Dim objType As Type = hashtableObj.GetType()
      Dim arrayMemberInfo() As MemberInfo
      Dim arrayMethodInfo() As MethodInfo
      Try
         ' Get the methods implemented in 'IDeserializationCallback'
 interface.
         arrayMethodInfo = objType.GetInterface("IDeserializationCallback").GetMethods()
         Console.WriteLine(ControlChars.Cr + "Methods of
 'IDeserializationCallback' Interface :")
         Dim index As Integer
         For index = 0 To arrayMethodInfo.Length
 - 1
            Console.WriteLine(arrayMethodInfo(index).ToString())
         Next index
         ' Get FullName for interface by using Ignore case search.
         Console.WriteLine(ControlChars.Cr + "Methods of
 'IEnumerable' Interface")
         arrayMethodInfo = objType.GetInterface("ienumerable",
 True).GetMethods()
         For index = 0 To arrayMethodInfo.Length
 - 1
            Console.WriteLine(arrayMethodInfo(index).ToString())
         Next index
         'Get the Interface methods for 'IDictionary' interface
         Dim interfaceMappingObj As InterfaceMapping
         interfaceMappingObj = objType.GetInterfaceMap(GetType(IDictionary))
         arrayMemberInfo = interfaceMappingObj.InterfaceMethods
         Console.WriteLine(ControlChars.Cr + "Hashtable class
 Implements the following IDictionary Interface methods :")
         For index = 0 To arrayMemberInfo.Length
 - 1
            Console.WriteLine(arrayMemberInfo(index).ToString())
         Next index
      Catch e As Exception
         Console.WriteLine(("Exception : " + e.ToString()))
      End Try
   End Sub 'Main
End Class 'MyInterfaceClass 
public static void Main()
{
    Hashtable hashtableObj = new Hashtable();
    Type objType = hashtableObj.GetType();
    MemberInfo[] arrayMemberInfo;
    MethodInfo[] arrayMethodInfo;
    try
    {   
        // Get the methods implemented in 'IDeserializationCallback'
 interface.
        arrayMethodInfo =objType.GetInterface("IDeserializationCallback").GetMethods();
        Console.WriteLine ("\nMethods of 'IDeserializationCallback' Interface
 :");
        for(int index=0;index < arrayMethodInfo.Length
 ;index++)
            Console.WriteLine (arrayMethodInfo[index].ToString() ); 

        // Get FullName for interface by using Ignore case search.
        Console.WriteLine ("\nMethods of 'IEnumerable' Interface");
        arrayMethodInfo = objType.GetInterface("ienumerable",true).GetMethods();
        for(int index=0;index < arrayMethodInfo.Length
 ;index++)
           Console.WriteLine (arrayMethodInfo[index].ToString()); 
       
        //Get the Interface methods for 'IDictionary' interface
        InterfaceMapping interfaceMappingObj;
        interfaceMappingObj = objType.GetInterfaceMap(typeof(IDictionary));
        arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
        Console.WriteLine ("\nHashtable class Implements
 the following IDictionary Interface methods :");
        for(int index=0; index < arrayMemberInfo.Length;
 index++)
            Console.WriteLine (arrayMemberInfo[index].ToString() ); 
    }
    catch (Exception e)
    {
        Console.WriteLine ("Exception : " + e.ToString());            
    }                 
}
int main()
{
   Hashtable^ hashtableObj = gcnew Hashtable;
   Type^ objType = hashtableObj->GetType();
   array<MemberInfo^>^arrayMemberInfo;
   array<MethodInfo^>^arrayMethodInfo;
   try
   {
      // Get the methods implemented in 'IDeserializationCallback' interface.
      arrayMethodInfo = objType->GetInterface( "IDeserializationCallback"
 )->GetMethods();
      Console::WriteLine( "\nMethods of 'IDeserializationCallback' Interface
 :" );
      for ( int index = 0; index < arrayMethodInfo->Length;
 index++ )
         Console::WriteLine( arrayMethodInfo[ index ] );
      
      // Get FullName for interface by using Ignore case search.
      Console::WriteLine( "\nMethods of 'IEnumerable' Interface" );
      arrayMethodInfo = objType->GetInterface( "ienumerable", true
 )->GetMethods();
      for ( int index = 0; index < arrayMethodInfo->Length;
 index++ )
         Console::WriteLine( arrayMethodInfo[ index ] );
      
      //Get the Interface methods for 'IDictionary*' interface
      InterfaceMapping interfaceMappingObj;
      interfaceMappingObj = objType->GetInterfaceMap( IDictionary::typeid );
      arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
      Console::WriteLine( "\nHashtable class Implements the
 following IDictionary Interface methods :" );
      for ( int index = 0; index < arrayMemberInfo->Length;
 index++ )
         Console::WriteLine( arrayMemberInfo[ index ] );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception : {0}", e );
   }
}
public static void main(String[]
 args)
{
    Hashtable hashtableObj = new Hashtable();
    Type objType = hashtableObj.GetType();
    MemberInfo arrayMemberInfo[];
    MethodInfo arrayMethodInfo[];
    try {
        // Get the methods implemented in 'IDeserializationCallback'
        // interface.
        arrayMethodInfo = objType.GetInterface("IDeserializationCallback").
            GetMethods();
        Console.WriteLine("\nMethods of 'IDeserializationCallback'"
            + " Interface :");
        for (int index = 0; index < arrayMethodInfo.length;
 index++) {
            Console.WriteLine(arrayMethodInfo.get_Item(index).ToString());
        }
        // Get FullName for interface by using Ignore case search.
        Console.WriteLine("\nMethods of 'IEnumerable' Interface");
        arrayMethodInfo = objType.GetInterface("ienumerable", true).
            GetMethods();
        for (int index = 0; index < arrayMethodInfo.length;
 index++) {
            Console.WriteLine(arrayMethodInfo.get_Item(index).ToString());
        }
        //Get the Interface methods for 'IDictionary' interface
        InterfaceMapping interfaceMappingObj;
        interfaceMappingObj =
            objType.GetInterfaceMap(IDictionary.class.ToType());
        arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
        Console.WriteLine("\nHashtable class Implements the
 following"
            + " IDictionary Interface methods :");
        for (int index = 0; index < arrayMemberInfo.length;
 index++) {
            Console.WriteLine(arrayMemberInfo.get_Item(index).ToString());
        }
    }
    catch (System.Exception e) {
        Console.WriteLine("Exception : " + e.ToString());
    }
} //main
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Type.GetInterface メソッド


Type.GetInterface メソッド (String, Boolean)

派生クラスでオーバーライドされた場合、大文字と小文字を区別するかどうかを指定して、指定したインターフェイスを検索します。

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

例外例外
例外の種類条件

ArgumentNullException

name が null 参照 (Visual Basic では Nothing) です。

AmbiguousMatchException

現在の Type は、別の型引数で同じジェネリック インターフェイスを実装する型を表します。

解説解説
使用例使用例
   Public Shared Sub Main()
      Dim hashtableObj As New
 Hashtable()
      Dim objType As Type = hashtableObj.GetType()
      Dim arrayMemberInfo() As MemberInfo
      Dim arrayMethodInfo() As MethodInfo
      Try
         ' Get the methods implemented in 'IDeserializationCallback'
 interface.
         arrayMethodInfo = objType.GetInterface("IDeserializationCallback").GetMethods()
         Console.WriteLine(ControlChars.Cr + "Methods of
 'IDeserializationCallback' Interface :")
         Dim index As Integer
         For index = 0 To arrayMethodInfo.Length
 - 1
            Console.WriteLine(arrayMethodInfo(index).ToString())
         Next index
         ' Get FullName for interface by using Ignore case search.
         Console.WriteLine(ControlChars.Cr + "Methods of
 'IEnumerable' Interface")
         arrayMethodInfo = objType.GetInterface("ienumerable",
 True).GetMethods()
         For index = 0 To arrayMethodInfo.Length
 - 1
            Console.WriteLine(arrayMethodInfo(index).ToString())
         Next index
         'Get the Interface methods for 'IDictionary' interface
         Dim interfaceMappingObj As InterfaceMapping
         interfaceMappingObj = objType.GetInterfaceMap(GetType(IDictionary))
         arrayMemberInfo = interfaceMappingObj.InterfaceMethods
         Console.WriteLine(ControlChars.Cr + "Hashtable class
 Implements the following IDictionary Interface methods :")
         For index = 0 To arrayMemberInfo.Length
 - 1
            Console.WriteLine(arrayMemberInfo(index).ToString())
         Next index
      Catch e As Exception
         Console.WriteLine(("Exception : " + e.ToString()))
      End Try
   End Sub 'Main
End Class 'MyInterfaceClass 
public static void Main()
{
    Hashtable hashtableObj = new Hashtable();
    Type objType = hashtableObj.GetType();
    MemberInfo[] arrayMemberInfo;
    MethodInfo[] arrayMethodInfo;
    try
    {   
        // Get the methods implemented in 'IDeserializationCallback'
 interface.
        arrayMethodInfo =objType.GetInterface("IDeserializationCallback").GetMethods();
        Console.WriteLine ("\nMethods of 'IDeserializationCallback' Interface
 :");
        for(int index=0;index < arrayMethodInfo.Length
 ;index++)
            Console.WriteLine (arrayMethodInfo[index].ToString() ); 

        // Get FullName for interface by using Ignore case search.
        Console.WriteLine ("\nMethods of 'IEnumerable' Interface");
        arrayMethodInfo = objType.GetInterface("ienumerable",true).GetMethods();
        for(int index=0;index < arrayMethodInfo.Length
 ;index++)
           Console.WriteLine (arrayMethodInfo[index].ToString()); 
       
        //Get the Interface methods for 'IDictionary' interface
        InterfaceMapping interfaceMappingObj;
        interfaceMappingObj = objType.GetInterfaceMap(typeof(IDictionary));
        arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
        Console.WriteLine ("\nHashtable class Implements
 the following IDictionary Interface methods :");
        for(int index=0; index < arrayMemberInfo.Length;
 index++)
            Console.WriteLine (arrayMemberInfo[index].ToString() ); 
    }
    catch (Exception e)
    {
        Console.WriteLine ("Exception : " + e.ToString());            
    }                 
}
int main()
{
   Hashtable^ hashtableObj = gcnew Hashtable;
   Type^ objType = hashtableObj->GetType();
   array<MemberInfo^>^arrayMemberInfo;
   array<MethodInfo^>^arrayMethodInfo;
   try
   {
      // Get the methods implemented in 'IDeserializationCallback' interface.
      arrayMethodInfo = objType->GetInterface( "IDeserializationCallback"
 )->GetMethods();
      Console::WriteLine( "\nMethods of 'IDeserializationCallback' Interface
 :" );
      for ( int index = 0; index < arrayMethodInfo->Length;
 index++ )
         Console::WriteLine( arrayMethodInfo[ index ] );
      
      // Get FullName for interface by using Ignore case search.
      Console::WriteLine( "\nMethods of 'IEnumerable' Interface" );
      arrayMethodInfo = objType->GetInterface( "ienumerable", true
 )->GetMethods();
      for ( int index = 0; index < arrayMethodInfo->Length;
 index++ )
         Console::WriteLine( arrayMethodInfo[ index ] );
      
      //Get the Interface methods for 'IDictionary*' interface
      InterfaceMapping interfaceMappingObj;
      interfaceMappingObj = objType->GetInterfaceMap( IDictionary::typeid );
      arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
      Console::WriteLine( "\nHashtable class Implements the
 following IDictionary Interface methods :" );
      for ( int index = 0; index < arrayMemberInfo->Length;
 index++ )
         Console::WriteLine( arrayMemberInfo[ index ] );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception : {0}", e );
   }
}
public static void main(String[]
 args)
{
    Hashtable hashtableObj = new Hashtable();
    Type objType = hashtableObj.GetType();
    MemberInfo arrayMemberInfo[];
    MethodInfo arrayMethodInfo[];
    try {
        // Get the methods implemented in 'IDeserializationCallback'
        // interface.
        arrayMethodInfo = objType.GetInterface("IDeserializationCallback").
            GetMethods();
        Console.WriteLine("\nMethods of 'IDeserializationCallback'"
            + " Interface :");
        for (int index = 0; index < arrayMethodInfo.length;
 index++) {
            Console.WriteLine(arrayMethodInfo.get_Item(index).ToString());
        }
        // Get FullName for interface by using Ignore case search.
        Console.WriteLine("\nMethods of 'IEnumerable' Interface");
        arrayMethodInfo = objType.GetInterface("ienumerable", true).
            GetMethods();
        for (int index = 0; index < arrayMethodInfo.length;
 index++) {
            Console.WriteLine(arrayMethodInfo.get_Item(index).ToString());
        }
        //Get the Interface methods for 'IDictionary' interface
        InterfaceMapping interfaceMappingObj;
        interfaceMappingObj =
            objType.GetInterfaceMap(IDictionary.class.ToType());
        arrayMemberInfo = interfaceMappingObj.InterfaceMethods;
        Console.WriteLine("\nHashtable class Implements the
 following"
            + " IDictionary Interface methods :");
        for (int index = 0; index < arrayMemberInfo.length;
 index++) {
            Console.WriteLine(arrayMemberInfo.get_Item(index).ToString());
        }
    }
    catch (System.Exception e) {
        Console.WriteLine("Exception : " + e.ToString());
    }
} //main
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

_Type.GetInterface メソッド




英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「Type.GetInterface」の関連用語

Type.GetInterfaceのお隣キーワード
検索ランキング

   

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



Type.GetInterfaceのページの著作権

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

©2026 GRAS Group, Inc.RSS