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

속성 값

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

참고

C 클래스를 반영할 때 생성된 열린 메서드 N<V,int> 가 발생하지 않지만 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>. 두 경우 모두 속성은 IsGenericMethodDefinition M을 나타내는 에 대해 MethodInfo 를 반환 true 합니다.

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

적용 대상

추가 정보