MethodInfo.IsGenericMethodDefinition 속성

정의

현재 MethodInfo가 제네릭 메서드 정의를 나타내는지 여부를 표시하는 값을 가져옵니다.

public:
 virtual property bool IsGenericMethodDefinition { bool get(); };
public override bool IsGenericMethodDefinition { get; }
member this.IsGenericMethodDefinition : bool
Public Overrides ReadOnly Property IsGenericMethodDefinition As Boolean

속성 값

Boolean

MethodInfo 개체가 제네릭 메서드 정의를 나타내면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제에서는 속성을 사용 하 여 IsGenericMethodDefinition 제네릭 메서드 정의를 나타내는지 여부를 MethodInfo 나타내는 메시지를 표시 합니다.

이 예제는 메서드에 제공된 더 큰 예제의 MakeGenericMethod 일부입니다.

Console.WriteLine(vbTab _
    & "Is this a generic method definition? {0}", _
    mi.IsGenericMethodDefinition)
Console.WriteLine("\tIs this a generic method definition? {0}", 
    mi.IsGenericMethodDefinition);
Console::WriteLine("\tIs this a generic method definition? {0}", 
    mi->IsGenericMethodDefinition);

설명

현재 MethodInfo 가 제네릭 메서드 정의를 나타내는 경우 다음을 수행합니다.

제네릭 메서드의 IsGenericMethodDefinition 형식 매개 변수에 형식 인수가 할당되었는지 여부를 확인하려면 이 속성을 사용합니다. 형식 인수가 할당 IsGenericMethodDefinition 된 경우 일부 형식 인수 Type 가 바깥쪽 형식의 형식 매개 변수를 나타내는 개체인 경우에도 속성은 false를 반환합니다. 예를 들어 다음 C#, Visual Basic 및 C++ 코드를 고려합니다.

```cs
class C
{
    T N<T,U>(T t, U u) {...}
    public V M<V>(V v)
    {
        return N<V,int>(v, 42);
    }
}
```

```vb
Class C
    Public Function N(Of T,U)(ByVal ta As T, ByVal ua As U) As T
        ...
    End Function
    Public Function M(Of V)(ByVal va As V ) As V
        Return N(Of V, Integer)(va, 42)
    End Function
End Class
```

```cpp
ref class C
{
private:
    generic <typename T, typename U> T N(T t, U u) {...}
public:
    generic <typename V> V M(V v)
    {
        return N<V, int>(v, 42);
    }
};
```

M의 메서드 본문에는 M의 형식 매개 변수와 형식 Int32을 지정하는 메서드 N에 대한 호출이 포함됩니다. 이 속성은 IsGenericMethodDefinition 메서드 N<V,int>에 대해 false를 반환합니다.

참고

C 클래스를 반영할 때 개방형 생성 메서드 N<V,int> 가 발생하지 않지만 C를 동적 클래스로 내보내려면 C를 사용하여 MakeGenericMethod 생성해야 합니다.

제네릭 메서드 정의에 선언 형식의 제네릭 매개 변수가 포함된 경우 생성된 각 형식과 관련된 제네릭 메서드 정의가 있습니다. 예를 들어 다음 C# 및 Visual Basic 코드를 고려합니다.

```csharp
class B<U,V> {}
class C<T> { public B<T,S> M<S>() {...}}
```

```vb
Class B(Of U, V)
End Class
Class C(Of T)
    Public Function M(Of S)() As B(Of T, S)
        ...
    End Function
End Class
```

```cpp
generic <typename U, typename V> ref class B {};
generic <typename T> ref class C
{
public:
    generic <typename S> B<T,S>^ M() {...};
};
```

생성된 형식 C<int> (C(Of Integer)Visual Basic)에서 제네릭 메서드 M은 반환합니다B<int, S>. 열기 형식 C<T>에서 M은 .를 반환합니다 B<T, S>. 두 경우 모두 M을 IsGenericMethodDefinition 나타내는 속성이 MethodInfo 반환 true 됩니다.

제네릭 메서드와 관련된 용어에 대한 고정 조건 목록은 속성을 참조 IsGenericMethod 하세요. 제네릭 리플렉션에 사용되는 다른 용어에 대한 고정 조건 목록은 속성을 참조 IsGenericType 하세요.

적용 대상

추가 정보