MethodInfo.IsGenericMethodDefinition 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 MethodInfo 가 제네릭 메서드의 정의를 나타내는지 여부를 나타내는 값을 가져옵니다.
public:
virtual property bool IsGenericMethodDefinition { bool get(); };
public override bool IsGenericMethodDefinition { get; }
member this.IsGenericMethodDefinition : bool
Public Overrides ReadOnly Property IsGenericMethodDefinition As Boolean
속성 값
true 개체가 MethodInfo 제네릭 메서드의 정의를 나타내면 이고, false그렇지 않으면 .
예제
다음 코드 예제에서는 제네릭 메서드 정의를 나타내는지 여부를 MethodInfo 나타내는 메시지를 표시 하는 속성을 사용 합니다IsGenericMethodDefinition.
이 예제는 메서드에 제공된 더 큰 예제의 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은(는)true을(를) 반환합니다.메서드에서 반환된 배열의 각 Type 개체에 대해 다음을 수행합니다 GetGenericArguments() .
- 속성이 Type.IsGenericParameter 반환됩니다
true. - 현재 Type.DeclaringMethodMethodInfo를 반환합니다.
- 이 Type.GenericParameterPosition 속성은 배열에 있는 개체의 Type 위치와 동일합니다.
- 속성이 Type.IsGenericParameter 반환됩니다
제네릭 메서드의 IsGenericMethodDefinition 형식 매개 변수에 형식 인수가 할당되었는지 여부를 확인하려면 이 속성을 사용합니다. 형식 인수가 할당 IsGenericMethodDefinition 된 경우 일부 형식 인수 Type 가 바깥쪽 형식의 형식 매개 변수를 나타내는 개체인 경우에도 속성이 false를 반환합니다. 예를 들어, 다음 코드를 고려하세요.
```csharp
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를 동적 클래스로 내보내려면 이를 사용하여 MakeGenericMethod 생성해야 합니다.
제네릭 메서드 정의에 선언 형식의 제네릭 매개 변수가 포함된 경우 생성된 각 형식과 관련된 제네릭 메서드 정의가 있습니다. 예를 들어, 다음 코드를 고려하세요.
```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>(Visual Basic C(Of Integer))에서 제네릭 메서드 M은 B<int, S> 반환합니다. 열려 있는 형식 C<T>에서 M은 .를 반환합니다 B<T, S>. 두 경우 모두 M을 IsGenericMethodDefinition 나타내는 속성이 MethodInfo 반환 true 됩니다.
제네릭 메서드와 관련된 용어에 대한 고정 조건 목록은 속성을 참조 IsGenericMethod 하세요. 제네릭 리플렉션에 사용되는 다른 용어에 대한 고정 조건 목록은 속성을 참조하세요 IsGenericType .