Type.GetInterface メソッド (String)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As Type Dim name As String Dim returnValue As Type returnValue = instance.GetInterface(name)
戻り値
現在の Type で実装または継承されているインターフェイスのうち、指定した名前のインターフェイスが存在する場合は、そのインターフェイスを表す Type オブジェクト。それ以外の場合は null 参照 (Visual Basic では Nothing)。


現在の Type が構築ジェネリック型を表している場合、このメソッドは、型パラメータを適切な型の引数で置き換えて Type を返します。
現在の Type がジェネリック型定義またはジェネリック メソッド定義の型パラメータを表す場合、このメソッドはインターフェイス制約およびクラス制約またはインターフェイス制約から継承されたすべてのインターフェイスを検索します。
![]() |
---|
ジェネリック インターフェイスの場合、name パラメータは、抑音アクセント (`) および型パラメータの数で終わる完全修飾名です。ジェネリック インターフェイス定義と構築されたジェネリック インターフェイスの場合も同じです。たとえば、IExample<T> (Visual Basic の場合は IExample(Of T)) または IExample<string> (Visual Basic の場合は IExample(Of String)) を見つけるには、"IExample`1" を検索します。 |

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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Type.GetInterface メソッド

名前 | 説明 |
---|---|
Type.GetInterface (String) | 指定した名前のインターフェイスを検索します。 |
Type.GetInterface (String, Boolean) | 派生クラスでオーバーライドされた場合、大文字と小文字を区別するかどうかを指定して、指定したインターフェイスを検索します。 |

Type.GetInterface メソッド (String, Boolean)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As Type Dim name As String Dim ignoreCase As Boolean Dim returnValue As Type returnValue = instance.GetInterface(name, ignoreCase)
戻り値
現在の Type で実装または継承されているインターフェイスのうち、指定した名前のインターフェイスが存在する場合は、そのインターフェイスを表す Type オブジェクト。それ以外の場合は null 参照 (Visual Basic では Nothing)。


現在の Type が構築ジェネリック型を表している場合、このメソッドは、型パラメータを適切な型の引数で置き換えて Type を返します。
現在の Type がジェネリック型定義またはジェネリック メソッド定義の型パラメータを表す場合、このメソッドはインターフェイス制約およびクラス制約またはインターフェイス制約から継承されたすべてのインターフェイスを検索します。
![]() |
---|
ジェネリック インターフェイスの場合、name パラメータは、抑音アクセント (`) および型パラメータの数で終わる完全修飾名です。ジェネリック インターフェイス定義と構築されたジェネリック インターフェイスの場合も同じです。たとえば、IExample<T> (Visual Basic の場合は IExample(Of T)) または IExample<string> (Visual Basic の場合は IExample(Of String)) を見つけるには、"IExample`1" を検索します。 |

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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


_Type.GetInterface メソッド
- Type.GetInterfaceのページへのリンク