TypeBuilder.GetGenericTypeDefinition 方法

定義

傳回 Type 物件,代表可從中取得目前類型的泛型類型定義。Returns a Type object that represents a generic type definition from which the current type can be obtained.

public:
 override Type ^ GetGenericTypeDefinition();
public override Type GetGenericTypeDefinition ();
override this.GetGenericTypeDefinition : unit -> Type
Public Overrides Function GetGenericTypeDefinition () As Type

傳回

Type

Type 物件,代表可從中取得目前類型的泛型類型定義。A Type object representing a generic type definition from which the current type can be obtained.

例外狀況

目前的類型不是泛型。The current type is not generic. 亦即,IsGenericType 會傳回 falseThat is, IsGenericType returns false.

備註

如果您 GetGenericTypeDefinition 在屬性傳回的物件上呼叫方法 TypeBuilder IsGenericType true ,則屬性會傳回 GetGenericTypeDefinition 目前的實例。If you call the GetGenericTypeDefinition method on a TypeBuilder object for which the IsGenericType property returns true, the GetGenericTypeDefinition property returns the current instance. TypeBuilder代表泛型型別的,一律是泛型型別定義。A TypeBuilder that represents a generic type is always a generic type definition.

如果您使用 MakeGenericType 方法,從代表泛型型別定義的物件來建立泛型型別,則在已建立的 TypeBuilder 型別 Type.GetGenericTypeDefinition 上使用方法會傳回 TypeBuilder 代表泛型型別定義的物件。If you used the MakeGenericType method to construct a generic type from a TypeBuilder object that represents a generic type definition, using the Type.GetGenericTypeDefinition method on the constructed type gets back the TypeBuilder object that represents the generic type definition.

適用於

另請參閱