Type.GetInterfaces 메서드

정의

파생 클래스에서 재정의되면, 현재 Type에 의해 구현되거나 상속되는 모든 인터페이스를 가져옵니다.

public:
 abstract cli::array <Type ^> ^ GetInterfaces();
public abstract Type[] GetInterfaces ();
abstract member GetInterfaces : unit -> Type[]
Public MustOverride Function GetInterfaces () As Type()

반환

Type[]

현재 Type 에 의해 구현되거나 상속되는 모든 인터페이스를 나타내는 Type개체의 배열입니다.

또는 현재 Type에 의해 구현되거나 상속되는 인터페이스가 없는 경우 Type 형식의 빈 배열입니다.

구현

예외

정적 이니셜라이저가 호출되고 예외를 발생합니다.

예제

다음 예제에서는 지정 된 클래스의 형식을 가져오고 형식이 구현 하거나 상속 하는 모든 인터페이스를 표시 합니다. Visual Basic 예제를 컴파일하려면 다음 컴파일러 명령을 사용 합니다.

vbc type_getinterfaces1.vb /r:System.Web.dll /r:System.dll

using namespace System;
using namespace System::Collections::Generic;

void main()
{
    Console::WriteLine("\r\nInterfaces implemented by Dictionary<int, String^>:\r\n");
     
    for each (Type^ tinterface in Dictionary<int, String^>::typeid->GetInterfaces())
    {
        Console::WriteLine(tinterface->ToString());
    }

    //Console::ReadLine()      // Uncomment this line for Visual Studio. 
}

/* This example produces output similar to the following:

Interfaces implemented by Dictionary<int, String^>:

System.Collections.Generic.IDictionary`2[System.Int32,System.String]
System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collection.IEnumerable
System.Collection.IDictionary
System.Collection.ICollection
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.IDeserializationCallback
 */
using System;
using System.Collections.Generic;

public class Example
{
    static void Main()
    {
        Console.WriteLine("\r\nInterfaces implemented by Dictionary<int, string>:\r\n");

        foreach (Type tinterface in typeof(Dictionary<int, string>).GetInterfaces())
        {
            Console.WriteLine(tinterface.ToString());
        }

        //Console.ReadLine()      // Uncomment this line for Visual Studio.
    }
}

/* This example produces output similar to the following:

Interfaces implemented by Dictionary<int, string>:

System.Collections.Generic.IDictionary`2[System.Int32,System.String]
System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
System.Collection.IEnumerable
System.Collection.IDictionary
System.Collection.ICollection
System.Runtime.Serialization.ISerializable
System.Runtime.Serialization.IDeserializationCallback
 */
Imports System.Collections.Generic

Public Class Example

    Shared Sub Main()

        Console.WriteLine(vbCrLf & _
            "Interfaces implemented by Dictionary(Of Integer, String):" & vbCrLf)
        
        For Each tinterface As Type In GetType(Dictionary(Of Integer, String)).GetInterfaces()

            Console.WriteLine(tinterface.ToString())

        Next

        'Console.ReadLine()      ' Uncomment this line for Visual Studio. 
    End Sub
End Class

' This example produces output similar to the following:
'
'Interfaces implemented by Dictionary(Of Integer, String):
'System.Collections.Generic.IDictionary`2[System.Int32,System.String]
'System.Collections.Generic.ICollection`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
'System.Collections.Generic.IEnumerable`1[System.Collections.Generic.KeyValuePair`2[System.Int32,System.String]]
'System.Collection.IEnumerable
'System.Collection.IDictionary
'System.Collection.ICollection
'System.Runtime.Serialization.ISerializable
'System.Runtime.Serialization.IDeserializationCallback

설명

GetInterfaces메서드는 사전순 또는 선언 순서와 같은 특정 순서로 인터페이스를 반환 하지 않습니다. 코드는 인터페이스가 반환 되는 순서에 따라 달라 지는 것이 아니라 해당 순서가 다르기 때문에이를 결정 해야 합니다.

현재 Type 이 생성 된 제네릭 형식을 나타내는 경우이 메서드는 Type 형식 매개 변수를 적절 한 형식 인수로 대체 하 여 개체를 반환 합니다.

현재 Type 이 제네릭 형식 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내는 경우이 메서드는 인터페이스 제약 조건과 클래스 또는 인터페이스 제약 조건에서 상속 된 인터페이스를 검색 합니다.

적용 대상

추가 정보