Type.IsGenericParameter 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 Type 제네릭 형식 또는 메서드 정의에서 형식 매개 변수를 나타내는지 여부를 나타내는 값을 가져옵니다.
public:
abstract property bool IsGenericParameter { bool get(); };
public:
virtual property bool IsGenericParameter { bool get(); };
public abstract bool IsGenericParameter { get; }
public virtual bool IsGenericParameter { get; }
member this.IsGenericParameter : bool
Public MustOverride ReadOnly Property IsGenericParameter As Boolean
Public Overridable ReadOnly Property IsGenericParameter As Boolean
속성 값
true 개체가 Type 제네릭 형식 정의 또는 제네릭 메서드 정의의 형식 매개 변수를 나타내면 이고, false그렇지 않으면 .
예제
다음 예제에서는 속성을 IsGenericParameter 사용하여 제네릭 형식의 제네릭 형식 매개 변수를 테스트합니다.
if (t.IsGenericType)
{
// If this is a generic type, display the type arguments.
//
Type[] typeArguments = t.GetGenericArguments();
Console.WriteLine("\tList type arguments ({0}):",
typeArguments.Length);
foreach (Type tParam in typeArguments)
{
// If this is a type parameter, display its
// position.
//
if (tParam.IsGenericParameter)
{
Console.WriteLine("\t\t{0}\t(unassigned - parameter position {1})",
tParam,
tParam.GenericParameterPosition);
}
else
{
Console.WriteLine("\t\t{0}", tParam);
}
}
}
if t.IsGenericType then
// If this is a generic type, display the type arguments.
let typeArguments = t.GetGenericArguments()
printfn $"\tList type arguments ({typeArguments.Length}):"
for tParam in typeArguments do
// If this is a type parameter, display its position.
if tParam.IsGenericParameter then
printfn $"\t\t{tParam}\t(unassigned - parameter position {tParam.GenericParameterPosition})"
else
printfn $"\t\t{tParam}"
If t.IsGenericType Then
' If this is a generic type, display the type arguments.
'
Dim typeArguments As Type() = t.GetGenericArguments()
Console.WriteLine(vbTab & "List type arguments (" _
& typeArguments.Length & "):")
For Each tParam As Type In typeArguments
' If this is a type parameter, display its position.
'
If tParam.IsGenericParameter Then
Console.WriteLine(vbTab & vbTab & tParam.ToString() _
& vbTab & "(unassigned - parameter position " _
& tParam.GenericParameterPosition & ")")
Else
Console.WriteLine(vbTab & vbTab & tParam.ToString())
End If
Next tParam
End If
설명
Type제네릭 형식 정의를 나타내는 개체의 메서드 또는 GetGenericArguments 제네릭 메서드 정의를 나타내는 개체의 Type 메서드를 호출 GetGenericArguments 하여 제네릭 형식 매개 변수를 MethodInfo 나타내는 개체를 가져올 수 있습니다.
제네릭 형식 또는 메서드 정의의 경우 속성은 IsGenericParameter 결과 배열의 모든 요소에 대해 반환
true됩니다.닫힌 생성 형식 또는 메서드의 경우 메서드에서 IsGenericParameter 반환된 배열의 모든 요소에 대해 속성이 GetGenericArguments 반환
false됩니다.열린 생성된 형식 또는 메서드의 경우 배열의 일부 요소는 특정 형식일 수 있고 다른 요소는 형식 매개 변수일 수 있습니다. IsGenericParameter는 형식 및
true형식 매개 변수에 대해 반환false됩니다. 속성의 ContainsGenericParameters 코드 예제에서는 형식 및 형식 매개 변수가 혼합된 제네릭 클래스를 보여 줍니다.
제네릭 리플렉션에 사용되는 용어에 대한 고정 조건 목록은 속성 비고를 IsGenericType 참조하세요.