GenericTypeParameterBuilder 类

定义

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

public ref class GenericTypeParameterBuilder sealed : Type
public ref class GenericTypeParameterBuilder sealed : System::Reflection::TypeInfo
public ref class GenericTypeParameterBuilder abstract : System::Reflection::TypeInfo
public sealed class GenericTypeParameterBuilder : Type
public sealed class GenericTypeParameterBuilder : System.Reflection.TypeInfo
public abstract class GenericTypeParameterBuilder : System.Reflection.TypeInfo
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class GenericTypeParameterBuilder : Type
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class GenericTypeParameterBuilder : System.Reflection.TypeInfo
type GenericTypeParameterBuilder = class
    inherit Type
type GenericTypeParameterBuilder = class
    inherit TypeInfo
[<System.Runtime.InteropServices.ComVisible(true)>]
type GenericTypeParameterBuilder = class
    inherit Type
[<System.Runtime.InteropServices.ComVisible(true)>]
type GenericTypeParameterBuilder = class
    inherit TypeInfo
Public NotInheritable Class GenericTypeParameterBuilder
Inherits Type
Public NotInheritable Class GenericTypeParameterBuilder
Inherits TypeInfo
Public MustInherit Class GenericTypeParameterBuilder
Inherits TypeInfo
继承
GenericTypeParameterBuilder
继承
GenericTypeParameterBuilder
继承
GenericTypeParameterBuilder
属性

示例

下面的代码示例创建一个具有两个类型参数的泛型类型,并将其保存在程序集 GenericEmitExample1.dll 中。 可以使用 Ildasm.exe (IL 反汇编程序) 查看生成的类型。 有关定义动态泛型类型所涉及的步骤的更详细说明,请参阅 如何:使用反射发出定义泛型类型

using namespace System;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
using namespace System::Collections::Generic;

// Dummy class to satisfy TFirst constraints.
//
public ref class Example {};

// Define a trivial base class and two trivial interfaces 
// to use when demonstrating constraints.
//
public ref class ExampleBase {};
public interface class IExampleA {};
public interface class IExampleB {};

// Define a trivial type that can substitute for type parameter 
// TSecond.
//
public ref class ExampleDerived : ExampleBase, IExampleA, IExampleB {};

// List the constraint flags. The GenericParameterAttributes
// enumeration contains two sets of attributes, variance and
// constraints. For this example, only constraints are used.
//
static void ListConstraintAttributes( Type^ t )
{
   // Mask off the constraint flags. 
   GenericParameterAttributes constraints = 
       t->GenericParameterAttributes & 
       GenericParameterAttributes::SpecialConstraintMask;

   if ((constraints & GenericParameterAttributes::ReferenceTypeConstraint)
           != GenericParameterAttributes::None)
       Console::WriteLine( L"    ReferenceTypeConstraint");

   if ((constraints & GenericParameterAttributes::NotNullableValueTypeConstraint)
           != GenericParameterAttributes::None)
       Console::WriteLine( L"    NotNullableValueTypeConstraint");

   if ((constraints & GenericParameterAttributes::DefaultConstructorConstraint)
           != GenericParameterAttributes::None)
       Console::WriteLine( L"    DefaultConstructorConstraint");
}

static void DisplayGenericParameters( Type^ t )
{
   if (!t->IsGenericType)
   {
       Console::WriteLine( L"Type '{0}' is not generic." );
       return;
   }
   if (!t->IsGenericTypeDefinition)
       t = t->GetGenericTypeDefinition();

   array<Type^>^ typeParameters = t->GetGenericArguments();
   Console::WriteLine( L"\r\nListing {0} type parameters for type '{1}'.", 
       typeParameters->Length, t );

   for each ( Type^ tParam in typeParameters )
   {
       Console::WriteLine( L"\r\nType parameter {0}:", 
           tParam->ToString() );

       for each (Type^ c in tParam->GetGenericParameterConstraints())
       {
           if (c->IsInterface)
               Console::WriteLine( L"    Interface constraint: {0}", c);
           else
               Console::WriteLine( L"    Base type constraint: {0}", c);
       }
       ListConstraintAttributes(tParam);
   }
}

void main()
{
   // Define a dynamic assembly to contain the sample type. The
   // assembly will be run and also saved to disk, so
   // AssemblyBuilderAccess.RunAndSave is specified.
   //
   AppDomain^ myDomain = AppDomain::CurrentDomain;
   AssemblyName^ myAsmName = gcnew AssemblyName( L"GenericEmitExample1" );
   AssemblyBuilder^ myAssembly = myDomain->DefineDynamicAssembly( 
       myAsmName, AssemblyBuilderAccess::RunAndSave );

   // An assembly is made up of executable modules. For a single-
   // module assembly, the module name and file name are the same 
   // as the assembly name. 
   //
   ModuleBuilder^ myModule = myAssembly->DefineDynamicModule( 
       myAsmName->Name, String::Concat( myAsmName->Name, L".dll" ) );

   // Get type objects for the base class trivial interfaces to
   // be used as constraints.
   //
   Type^ baseType = ExampleBase::typeid; 
   Type^ interfaceA = IExampleA::typeid; 
   Type^ interfaceB = IExampleB::typeid;
   
   // Define the sample type.
   //
   TypeBuilder^ myType = myModule->DefineType( L"Sample", 
       TypeAttributes::Public );
   
   Console::WriteLine( L"Type 'Sample' is generic: {0}", 
       myType->IsGenericType );
   
   // Define type parameters for the type. Until you do this, 
   // the type is not generic, as the preceding and following 
   // WriteLine statements show. The type parameter names are
   // specified as an array of strings. To make the code
   // easier to read, each GenericTypeParameterBuilder is placed
   // in a variable with the same name as the type parameter.
   // 
   array<String^>^typeParamNames = {L"TFirst",L"TSecond"};
   array<GenericTypeParameterBuilder^>^typeParams = 
       myType->DefineGenericParameters( typeParamNames );

   GenericTypeParameterBuilder^ TFirst = typeParams[0];
   GenericTypeParameterBuilder^ TSecond = typeParams[1];

   Console::WriteLine( L"Type 'Sample' is generic: {0}", 
       myType->IsGenericType );
   
   // Apply constraints to the type parameters.
   //
   // A type that is substituted for the first parameter, TFirst,
   // must be a reference type and must have a parameterless
   // constructor.
   TFirst->SetGenericParameterAttributes( 
       GenericParameterAttributes::DefaultConstructorConstraint | 
       GenericParameterAttributes::ReferenceTypeConstraint 
   );

   // A type that is substituted for the second type
   // parameter must implement IExampleA and IExampleB, and
   // inherit from the trivial test class ExampleBase. The
   // interface constraints are specified as an array
   // containing the interface types. 
   array<Type^>^interfaceTypes = { interfaceA, interfaceB };
   TSecond->SetInterfaceConstraints( interfaceTypes );
   TSecond->SetBaseTypeConstraint( baseType );

   // The following code adds a private field named ExampleField,
   // of type TFirst.
   FieldBuilder^ exField = 
       myType->DefineField("ExampleField", TFirst, 
           FieldAttributes::Private);

   // Define a static method that takes an array of TFirst and 
   // returns a List<TFirst> containing all the elements of 
   // the array. To define this method it is necessary to create
   // the type List<TFirst> by calling MakeGenericType on the
   // generic type definition, generic<T> List. 
   // The parameter type is created by using the
   // MakeArrayType method. 
   //
   Type^ listOf = List::typeid;
   Type^ listOfTFirst = listOf->MakeGenericType(TFirst);
   array<Type^>^ mParamTypes = { TFirst->MakeArrayType() };

   MethodBuilder^ exMethod = 
       myType->DefineMethod("ExampleMethod", 
           MethodAttributes::Public | MethodAttributes::Static, 
           listOfTFirst, 
           mParamTypes);

   // Emit the method body. 
   // The method body consists of just three opcodes, to load 
   // the input array onto the execution stack, to call the 
   // List<TFirst> constructor that takes IEnumerable<TFirst>,
   // which does all the work of putting the input elements into
   // the list, and to return, leaving the list on the stack. The
   // hard work is getting the constructor.
   // 
   // The GetConstructor method is not supported on a 
   // GenericTypeParameterBuilder, so it is not possible to get 
   // the constructor of List<TFirst> directly. There are two
   // steps, first getting the constructor of generic<T> List and then
   // calling a method that converts it to the corresponding 
   // constructor of List<TFirst>.
   //
   // The constructor needed here is the one that takes an
   // IEnumerable<T>. Note, however, that this is not the 
   // generic type definition of generic<T> IEnumerable; instead, the
   // T from generic<T> List must be substituted for the T of 
   // generic<T> IEnumerable. (This seems confusing only because both
   // types have type parameters named T. That is why this example
   // uses the somewhat silly names TFirst and TSecond.) To get
   // the type of the constructor argument, take the generic
   // type definition generic<T> IEnumerable and 
   // call MakeGenericType with the first generic type parameter
   // of generic<T> List. The constructor argument list must be passed
   // as an array, with just one argument in this case.
   // 
   // Now it is possible to get the constructor of generic<T> List,
   // using GetConstructor on the generic type definition. To get
   // the constructor of List<TFirst>, pass List<TFirst> and
   // the constructor from generic<T> List to the static
   // TypeBuilder.GetConstructor method.
   //
   ILGenerator^ ilgen = exMethod->GetILGenerator();
        
   Type^ ienumOf = IEnumerable::typeid;
   Type^ TfromListOf = listOf->GetGenericArguments()[0];
   Type^ ienumOfT = ienumOf->MakeGenericType(TfromListOf);
   array<Type^>^ ctorArgs = {ienumOfT};

   ConstructorInfo^ ctorPrep = listOf->GetConstructor(ctorArgs);
   ConstructorInfo^ ctor = 
       TypeBuilder::GetConstructor(listOfTFirst, ctorPrep);

   ilgen->Emit(OpCodes::Ldarg_0);
   ilgen->Emit(OpCodes::Newobj, ctor);
   ilgen->Emit(OpCodes::Ret);

   // Create the type and save the assembly. 
   Type^ finished = myType->CreateType();
   myAssembly->Save( String::Concat( myAsmName->Name, L".dll" ) );

   // Invoke the method.
   // ExampleMethod is not generic, but the type it belongs to is
   // generic, so in order to get a MethodInfo that can be invoked
   // it is necessary to create a constructed type. The Example 
   // class satisfies the constraints on TFirst, because it is a 
   // reference type and has a default constructor. In order to
   // have a class that satisfies the constraints on TSecond, 
   // this code example defines the ExampleDerived type. These
   // two types are passed to MakeGenericMethod to create the
   // constructed type.
   //
   array<Type^>^ typeArgs = 
       { Example::typeid, ExampleDerived::typeid };
   Type^ constructed = finished->MakeGenericType(typeArgs);
   MethodInfo^ mi = constructed->GetMethod("ExampleMethod");

   // Create an array of Example objects, as input to the generic
   // method. This array must be passed as the only element of an 
   // array of arguments. The first argument of Invoke is 
   // null, because ExampleMethod is static. Display the count
   // on the resulting List<Example>.
   // 
   array<Example^>^ input = { gcnew Example(), gcnew Example() };
   array<Object^>^ arguments = { input };

   List<Example^>^ listX = 
       (List<Example^>^) mi->Invoke(nullptr, arguments);

   Console::WriteLine(
       "\nThere are {0} elements in the List<Example>.", 
       listX->Count);

   DisplayGenericParameters(finished);
}

/* This code example produces the following output:

Type 'Sample' is generic: False
Type 'Sample' is generic: True

There are 2 elements in the List<Example>.

Listing 2 type parameters for type 'Sample[TFirst,TSecond]'.

Type parameter TFirst:
    ReferenceTypeConstraint
    DefaultConstructorConstraint

Type parameter TSecond:
    Interface constraint: IExampleA
    Interface constraint: IExampleB
    Base type constraint: ExampleBase
 */
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections.Generic;

// Define a trivial base class and two trivial interfaces
// to use when demonstrating constraints.
//
public class ExampleBase {}

public interface IExampleA {}

public interface IExampleB {}

// Define a trivial type that can substitute for type parameter
// TSecond.
//
public class ExampleDerived : ExampleBase, IExampleA, IExampleB {}

public class Example
{
    public static void Main()
    {
        // Define a dynamic assembly to contain the sample type. The
        // assembly will not be run, but only saved to disk, so
        // AssemblyBuilderAccess.Save is specified.
        //
        AppDomain myDomain = AppDomain.CurrentDomain;
        AssemblyName myAsmName = new AssemblyName("GenericEmitExample1");
        AssemblyBuilder myAssembly =
            myDomain.DefineDynamicAssembly(myAsmName,
                AssemblyBuilderAccess.RunAndSave);

        // An assembly is made up of executable modules. For a single-
        // module assembly, the module name and file name are the same
        // as the assembly name.
        //
        ModuleBuilder myModule =
            myAssembly.DefineDynamicModule(myAsmName.Name,
               myAsmName.Name + ".dll");

        // Get type objects for the base class trivial interfaces to
        // be used as constraints.
        //
        Type baseType = typeof(ExampleBase);
        Type interfaceA = typeof(IExampleA);
        Type interfaceB = typeof(IExampleB);

        // Define the sample type.
        //
        TypeBuilder myType =
            myModule.DefineType("Sample", TypeAttributes.Public);

        Console.WriteLine("Type 'Sample' is generic: {0}",
            myType.IsGenericType);

        // Define type parameters for the type. Until you do this,
        // the type is not generic, as the preceding and following
        // WriteLine statements show. The type parameter names are
        // specified as an array of strings. To make the code
        // easier to read, each GenericTypeParameterBuilder is placed
        // in a variable with the same name as the type parameter.
        //
        string[] typeParamNames = {"TFirst", "TSecond"};
        GenericTypeParameterBuilder[] typeParams =
            myType.DefineGenericParameters(typeParamNames);

        GenericTypeParameterBuilder TFirst = typeParams[0];
        GenericTypeParameterBuilder TSecond = typeParams[1];

        Console.WriteLine("Type 'Sample' is generic: {0}",
            myType.IsGenericType);

        // Apply constraints to the type parameters.
        //
        // A type that is substituted for the first parameter, TFirst,
        // must be a reference type and must have a parameterless
        // constructor.
        TFirst.SetGenericParameterAttributes(
            GenericParameterAttributes.DefaultConstructorConstraint |
            GenericParameterAttributes.ReferenceTypeConstraint);

        // A type that is substituted for the second type
        // parameter must implement IExampleA and IExampleB, and
        // inherit from the trivial test class ExampleBase. The
        // interface constraints are specified as an array
        // containing the interface types.
        TSecond.SetBaseTypeConstraint(baseType);
        Type[] interfaceTypes = {interfaceA, interfaceB};
        TSecond.SetInterfaceConstraints(interfaceTypes);

        // The following code adds a private field named ExampleField,
        // of type TFirst.
        FieldBuilder exField =
            myType.DefineField("ExampleField", TFirst,
                FieldAttributes.Private);

        // Define a static method that takes an array of TFirst and
        // returns a List<TFirst> containing all the elements of
        // the array. To define this method it is necessary to create
        // the type List<TFirst> by calling MakeGenericType on the
        // generic type definition, List<T>. (The T is omitted with
        // the typeof operator when you get the generic type
        // definition.) The parameter type is created by using the
        // MakeArrayType method.
        //
        Type listOf = typeof(List<>);
        Type listOfTFirst = listOf.MakeGenericType(TFirst);
        Type[] mParamTypes = {TFirst.MakeArrayType()};

        MethodBuilder exMethod =
            myType.DefineMethod("ExampleMethod",
                MethodAttributes.Public | MethodAttributes.Static,
                listOfTFirst,
                mParamTypes);

        // Emit the method body.
        // The method body consists of just three opcodes, to load
        // the input array onto the execution stack, to call the
        // List<TFirst> constructor that takes IEnumerable<TFirst>,
        // which does all the work of putting the input elements into
        // the list, and to return, leaving the list on the stack. The
        // hard work is getting the constructor.
        //
        // The GetConstructor method is not supported on a
        // GenericTypeParameterBuilder, so it is not possible to get
        // the constructor of List<TFirst> directly. There are two
        // steps, first getting the constructor of List<T> and then
        // calling a method that converts it to the corresponding
        // constructor of List<TFirst>.
        //
        // The constructor needed here is the one that takes an
        // IEnumerable<T>. Note, however, that this is not the
        // generic type definition of IEnumerable<T>; instead, the
        // T from List<T> must be substituted for the T of
        // IEnumerable<T>. (This seems confusing only because both
        // types have type parameters named T. That is why this example
        // uses the somewhat silly names TFirst and TSecond.) To get
        // the type of the constructor argument, take the generic
        // type definition IEnumerable<T> (expressed as
        // IEnumerable<> when you use the typeof operator) and
        // call MakeGenericType with the first generic type parameter
        // of List<T>. The constructor argument list must be passed
        // as an array, with just one argument in this case.
        //
        // Now it is possible to get the constructor of List<T>,
        // using GetConstructor on the generic type definition. To get
        // the constructor of List<TFirst>, pass List<TFirst> and
        // the constructor from List<T> to the static
        // TypeBuilder.GetConstructor method.
        //
        ILGenerator ilgen = exMethod.GetILGenerator();

        Type ienumOf = typeof(IEnumerable<>);
        Type TfromListOf = listOf.GetGenericArguments()[0];
        Type ienumOfT = ienumOf.MakeGenericType(TfromListOf);
        Type[] ctorArgs = {ienumOfT};

        ConstructorInfo ctorPrep = listOf.GetConstructor(ctorArgs);
        ConstructorInfo ctor =
            TypeBuilder.GetConstructor(listOfTFirst, ctorPrep);

        ilgen.Emit(OpCodes.Ldarg_0);
        ilgen.Emit(OpCodes.Newobj, ctor);
        ilgen.Emit(OpCodes.Ret);

        // Create the type and save the assembly.
        Type finished = myType.CreateType();
        myAssembly.Save(myAsmName.Name+".dll");

        // Invoke the method.
        // ExampleMethod is not generic, but the type it belongs to is
        // generic, so in order to get a MethodInfo that can be invoked
        // it is necessary to create a constructed type. The Example
        // class satisfies the constraints on TFirst, because it is a
        // reference type and has a default constructor. In order to
        // have a class that satisfies the constraints on TSecond,
        // this code example defines the ExampleDerived type. These
        // two types are passed to MakeGenericMethod to create the
        // constructed type.
        //
        Type[] typeArgs = {typeof(Example), typeof(ExampleDerived)};
        Type constructed = finished.MakeGenericType(typeArgs);
        MethodInfo mi = constructed.GetMethod("ExampleMethod");

        // Create an array of Example objects, as input to the generic
        // method. This array must be passed as the only element of an
        // array of arguments. The first argument of Invoke is
        // null, because ExampleMethod is static. Display the count
        // on the resulting List<Example>.
        //
        Example[] input = {new Example(), new Example()};
        object[] arguments = {input};

        List<Example> listX =
            (List<Example>) mi.Invoke(null, arguments);

        Console.WriteLine(
            "\nThere are {0} elements in the List<Example>.",
            listX.Count);

        DisplayGenericParameters(finished);
    }

    private static void DisplayGenericParameters(Type t)
    {
        if (!t.IsGenericType)
        {
            Console.WriteLine("Type '{0}' is not generic.");
            return;
        }
        if (!t.IsGenericTypeDefinition)
        {
            t = t.GetGenericTypeDefinition();
        }

        Type[] typeParameters = t.GetGenericArguments();
        Console.WriteLine("\nListing {0} type parameters for type '{1}'.",
            typeParameters.Length, t);

        foreach( Type tParam in typeParameters )
        {
            Console.WriteLine("\r\nType parameter {0}:", tParam.ToString());

            foreach( Type c in tParam.GetGenericParameterConstraints() )
            {
                if (c.IsInterface)
                {
                    Console.WriteLine("    Interface constraint: {0}", c);
                }
                else
                {
                    Console.WriteLine("    Base type constraint: {0}", c);
                }
            }

            ListConstraintAttributes(tParam);
        }
    }

    // List the constraint flags. The GenericParameterAttributes
    // enumeration contains two sets of attributes, variance and
    // constraints. For this example, only constraints are used.
    //
    private static void ListConstraintAttributes(Type t)
    {
        // Mask off the constraint flags.
        GenericParameterAttributes constraints =
            t.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask;

        if ((constraints & GenericParameterAttributes.ReferenceTypeConstraint)
            != GenericParameterAttributes.None)
        {
            Console.WriteLine("    ReferenceTypeConstraint");
        }

        if ((constraints & GenericParameterAttributes.NotNullableValueTypeConstraint)
            != GenericParameterAttributes.None)
        {
            Console.WriteLine("    NotNullableValueTypeConstraint");
        }

        if ((constraints & GenericParameterAttributes.DefaultConstructorConstraint)
            !=GenericParameterAttributes.None)
        {
            Console.WriteLine("    DefaultConstructorConstraint");
        }
    }
}

/* This code example produces the following output:

Type 'Sample' is generic: False
Type 'Sample' is generic: True

There are 2 elements in the List<Example>.

Listing 2 type parameters for type 'Sample[TFirst,TSecond]'.

Type parameter TFirst:
    ReferenceTypeConstraint
    DefaultConstructorConstraint

Type parameter TSecond:
    Interface constraint: IExampleA
    Interface constraint: IExampleB
    Base type constraint: ExampleBase
 */
Imports System.Reflection
Imports System.Reflection.Emit
Imports System.Collections.Generic

' Define a trivial base class and two trivial interfaces 
' to use when demonstrating constraints.
'
Public Class ExampleBase
End Class

Public Interface IExampleA
End Interface

Public Interface IExampleB
End Interface

' Define a trivial type that can substitute for type parameter 
' TSecond.
'
Public Class ExampleDerived
    Inherits ExampleBase
    Implements IExampleA, IExampleB
End Class

Public Class Example
    Public Shared Sub Main()
        ' Define a dynamic assembly to contain the sample type. The
        ' assembly will not be run, but only saved to disk, so
        ' AssemblyBuilderAccess.Save is specified.
        '
        Dim myDomain As AppDomain = AppDomain.CurrentDomain
        Dim myAsmName As New AssemblyName("GenericEmitExample1")
        Dim myAssembly As AssemblyBuilder = myDomain.DefineDynamicAssembly( _
            myAsmName, _
            AssemblyBuilderAccess.RunAndSave)

        ' An assembly is made up of executable modules. For a single-
        ' module assembly, the module name and file name are the same 
        ' as the assembly name. 
        '
        Dim myModule As ModuleBuilder = myAssembly.DefineDynamicModule( _
            myAsmName.Name, _
            myAsmName.Name & ".dll")

        ' Get type objects for the base class trivial interfaces to
        ' be used as constraints.
        '
        Dim baseType As Type = GetType(ExampleBase)
        Dim interfaceA As Type = GetType(IExampleA)
        Dim interfaceB As Type = GetType(IExampleB)
                
        ' Define the sample type.
        '
        Dim myType As TypeBuilder = myModule.DefineType( _
            "Sample", _
            TypeAttributes.Public)

        Console.WriteLine("Type 'Sample' is generic: {0}", _
            myType.IsGenericType)

        ' Define type parameters for the type. Until you do this, 
        ' the type is not generic, as the preceding and following 
        ' WriteLine statements show. The type parameter names are
        ' specified as an array of strings. To make the code
        ' easier to read, each GenericTypeParameterBuilder is placed
        ' in a variable with the same name as the type parameter.
        ' 
        Dim typeParamNames() As String = {"TFirst", "TSecond"}
        Dim typeParams() As GenericTypeParameterBuilder = _
            myType.DefineGenericParameters(typeParamNames)

        Dim TFirst As GenericTypeParameterBuilder = typeParams(0)
        Dim TSecond As GenericTypeParameterBuilder = typeParams(1)

        Console.WriteLine("Type 'Sample' is generic: {0}", _
            myType.IsGenericType)

        ' Apply constraints to the type parameters.
        '
        ' A type that is substituted for the first parameter, TFirst,
        ' must be a reference type and must have a parameterless
        ' constructor.
        TFirst.SetGenericParameterAttributes( _
            GenericParameterAttributes.DefaultConstructorConstraint _
            Or GenericParameterAttributes.ReferenceTypeConstraint)

        ' A type that is substituted for the second type
        ' parameter must implement IExampleA and IExampleB, and
        ' inherit from the trivial test class ExampleBase. The
        ' interface constraints are specified as an array 
        ' containing the interface types.
        TSecond.SetBaseTypeConstraint(baseType)
        Dim interfaceTypes() As Type = {interfaceA, interfaceB}
        TSecond.SetInterfaceConstraints(interfaceTypes)

        ' The following code adds a private field named ExampleField,
        ' of type TFirst.
        Dim exField As FieldBuilder = _
            myType.DefineField("ExampleField", TFirst, _
                FieldAttributes.Private)

        ' Define a Shared method that takes an array of TFirst and 
        ' returns a List(Of TFirst) containing all the elements of 
        ' the array. To define this method it is necessary to create
        ' the type List(Of TFirst) by calling MakeGenericType on the
        ' generic type definition, List(Of T). (The T is omitted with
        ' the GetType operator when you get the generic type 
        ' definition.) The parameter type is created by using the
        ' MakeArrayType method. 
        '
        Dim listOf As Type = GetType(List(Of ))
        Dim listOfTFirst As Type = listOf.MakeGenericType(TFirst)
        Dim mParamTypes() As Type = { TFirst.MakeArrayType() }

        Dim exMethod As MethodBuilder = _
            myType.DefineMethod("ExampleMethod", _
                MethodAttributes.Public Or MethodAttributes.Static, _
                listOfTFirst, _
                mParamTypes)

        ' Emit the method body. 
        ' The method body consists of just three opcodes, to load 
        ' the input array onto the execution stack, to call the 
        ' List(Of TFirst) constructor that takes IEnumerable(Of TFirst),
        ' which does all the work of putting the input elements into
        ' the list, and to return, leaving the list on the stack. The
        ' hard work is getting the constructor.
        ' 
        ' The GetConstructor method is not supported on a 
        ' GenericTypeParameterBuilder, so it is not possible to get 
        ' the constructor of List(Of TFirst) directly. There are two
        ' steps, first getting the constructor of List(Of T) and then
        ' calling a method that converts it to the corresponding 
        ' constructor of List(Of TFirst).
        '
        ' The constructor needed here is the one that takes an
        ' IEnumerable(Of T). Note, however, that this is not the 
        ' generic type definition of IEnumerable(Of T); instead, the
        ' T from List(Of T) must be substituted for the T of 
        ' IEnumerable(Of T). (This seems confusing only because both
        ' types have type parameters named T. That is why this example
        ' uses the somewhat silly names TFirst and TSecond.) To get
        ' the type of the constructor argument, take the generic
        ' type definition IEnumerable(Of T) (expressed as 
        ' IEnumerable(Of ) when you use the GetType operator) and 
        ' call MakeGenericType with the first generic type parameter
        ' of List(Of T). The constructor argument list must be passed
        ' as an array, with just one argument in this case.
        ' 
        ' Now it is possible to get the constructor of List(Of T),
        ' using GetConstructor on the generic type definition. To get
        ' the constructor of List(Of TFirst), pass List(Of TFirst) and
        ' the constructor from List(Of T) to the static
        ' TypeBuilder.GetConstructor method.
        '
        Dim ilgen As ILGenerator = exMethod.GetILGenerator()
        
        Dim ienumOf As Type = GetType(IEnumerable(Of ))
        Dim listOfTParams() As Type = listOf.GetGenericArguments()
        Dim TfromListOf As Type = listOfTParams(0)
        Dim ienumOfT As Type = ienumOf.MakeGenericType(TfromListOf)
        Dim ctorArgs() As Type = { ienumOfT }

        Dim ctorPrep As ConstructorInfo = _
            listOf.GetConstructor(ctorArgs)
        Dim ctor As ConstructorInfo = _
            TypeBuilder.GetConstructor(listOfTFirst, ctorPrep)

        ilgen.Emit(OpCodes.Ldarg_0)
        ilgen.Emit(OpCodes.Newobj, ctor)
        ilgen.Emit(OpCodes.Ret)

        ' Create the type and save the assembly. 
        Dim finished As Type = myType.CreateType()
        myAssembly.Save(myAsmName.Name & ".dll")

        ' Invoke the method.
        ' ExampleMethod is not generic, but the type it belongs to is
        ' generic, so in order to get a MethodInfo that can be invoked
        ' it is necessary to create a constructed type. The Example 
        ' class satisfies the constraints on TFirst, because it is a 
        ' reference type and has a default constructor. In order to
        ' have a class that satisfies the constraints on TSecond, 
        ' this code example defines the ExampleDerived type. These
        ' two types are passed to MakeGenericMethod to create the
        ' constructed type.
        '
        Dim typeArgs() As Type = _
            { GetType(Example), GetType(ExampleDerived) }
        Dim constructed As Type = finished.MakeGenericType(typeArgs)
        Dim mi As MethodInfo = constructed.GetMethod("ExampleMethod")

        ' Create an array of Example objects, as input to the generic
        ' method. This array must be passed as the only element of an 
        ' array of arguments. The first argument of Invoke is 
        ' Nothing, because ExampleMethod is Shared. Display the count
        ' on the resulting List(Of Example).
        ' 
        Dim input() As Example = { New Example(), New Example() }
        Dim arguments() As Object = { input }

        Dim listX As List(Of Example) = mi.Invoke(Nothing, arguments)

        Console.WriteLine(vbLf & _
            "There are {0} elements in the List(Of Example).", _
            listX.Count _ 
        )

        DisplayGenericParameters(finished)
    End Sub

    Private Shared Sub DisplayGenericParameters(ByVal t As Type)

        If Not t.IsGenericType Then
            Console.WriteLine("Type '{0}' is not generic.")
            Return
        End If
        If Not t.IsGenericTypeDefinition Then _
            t = t.GetGenericTypeDefinition()

        Dim typeParameters() As Type = t.GetGenericArguments()
        Console.WriteLine(vbCrLf & _
            "Listing {0} type parameters for type '{1}'.", _
            typeParameters.Length, t)

        For Each tParam As Type In typeParameters

            Console.WriteLine(vbCrLf & "Type parameter {0}:", _
                tParam.ToString())

            For Each c As Type In tParam.GetGenericParameterConstraints()
                If c.IsInterface Then
                    Console.WriteLine("    Interface constraint: {0}", c)
                Else
                    Console.WriteLine("    Base type constraint: {0}", c)
                End If
            Next 

            ListConstraintAttributes(tParam)
        Next tParam
    End Sub

    ' List the constraint flags. The GenericParameterAttributes
    ' enumeration contains two sets of attributes, variance and
    ' constraints. For this example, only constraints are used.
    '
    Private Shared Sub ListConstraintAttributes(ByVal t As Type)

        ' Mask off the constraint flags. 
        Dim constraints As GenericParameterAttributes = _
            t.GenericParameterAttributes And _
            GenericParameterAttributes.SpecialConstraintMask

        If (constraints And GenericParameterAttributes.ReferenceTypeConstraint) _
                <> GenericParameterAttributes.None Then _
            Console.WriteLine("    ReferenceTypeConstraint")

        If (constraints And GenericParameterAttributes.NotNullableValueTypeConstraint) _
                <> GenericParameterAttributes.None Then _
            Console.WriteLine("    NotNullableValueTypeConstraint")

        If (constraints And GenericParameterAttributes.DefaultConstructorConstraint) _
                <> GenericParameterAttributes.None Then _
            Console.WriteLine("    DefaultConstructorConstraint")

    End Sub 

End Class

' This code example produces the following output:
'
'Type 'Sample' is generic: False
'Type 'Sample' is generic: True
'
'There are 2 elements in the List(Of Example).
'
'Listing 2 type parameters for type 'Sample[TFirst,TSecond]'.
'
'Type parameter TFirst:
'    ReferenceTypeConstraint
'    DefaultConstructorConstraint
'
'Type parameter TSecond:
'    Interface constraint: IExampleA
'    Interface constraint: IExampleB
'    Base type constraint: ExampleBase

注解

通过使用 方法将类型参数添加到动态类型,从而使其成为泛型类型,或使用 MethodBuilder.DefineGenericParameters 方法将类型参数添加到动态方法中,可以获取对象的TypeBuilder.DefineGenericParameters数组GenericTypeParameterBuilder。 使用 GenericTypeParameterBuilder 对象向类型参数添加约束。 约束有三种类型:

  • 基类型约束指定分配给泛型类型参数的任何类型都必须派生自特定的基类型。 使用 SetBaseTypeConstraint 方法设置此约束。

  • 接口约束指定分配给泛型类型参数的任何类型都必须实现特定的接口。 使用 SetInterfaceConstraints 方法设置接口约束。

  • 特殊约束指定分配给泛型类型参数的任何类型都必须具有无参数构造函数、必须是引用类型或必须是值类型。 使用 SetGenericParameterAttributes 方法设置类型参数的特殊约束。

无法使用 类的方法 GenericTypeParameterBuilder 检索接口约束和特殊约束。 创建包含类型参数的泛型类型后,可以使用其 Type 对象来反映约束。 Type.GetGenericArguments使用 方法获取类型参数,对于每个类型参数,使用 Type.GetGenericParameterConstraints 方法获取基类型约束和接口约束,使用 Type.GenericParameterAttributes 属性获取特殊约束。

构造函数

GenericTypeParameterBuilder()

初始化 GenericTypeParameterBuilder 类的新实例。

属性

Assembly

获取 Assembly 对象,该对象表示包含当前类型参数所属的泛型类型定义的动态程序集。

AssemblyQualifiedName

在所有情况下均获取 null

Attributes

获取与 Type 关联的属性。

Attributes

获取与 Type 关联的属性。

(继承自 Type)
Attributes

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
BaseType

获取当前泛型类型参数的基类型约束。

ContainsGenericParameters

在所有情况下均获取 true

CustomAttributes

获取包含此成员自定义属性的集合。

(继承自 MemberInfo)
DeclaredConstructors

获取由当前类型声明的构造函数的集合。

(继承自 TypeInfo)
DeclaredEvents

获取由当前类型定义的事件的集合。

(继承自 TypeInfo)
DeclaredFields

获取由当前类型定义的字段的集合。

(继承自 TypeInfo)
DeclaredMembers

获取由当前类型定义的成员的集合。

(继承自 TypeInfo)
DeclaredMethods

获取由当前类型定义的方法的集合。

(继承自 TypeInfo)
DeclaredNestedTypes

获取由当前类型定义的嵌套类型的集合。

(继承自 TypeInfo)
DeclaredProperties

获取由当前类型定义的属性的集合。

(继承自 TypeInfo)
DeclaringMethod

获取一个表示声明方法的 MethodInfo(如果当前 GenericTypeParameterBuilder 表示泛型方法的一个类型参数)。

DeclaringType

获取泛型类型定义或泛型类型参数所属的泛型方法定义。

FullName

在所有情况下均获取 null

GenericParameterAttributes

获取描述当前泛型类型参数的协变和特殊约束的 GenericParameterAttributes 标志。

GenericParameterAttributes

获取描述当前泛型类型参数的协变和特殊约束的 GenericParameterAttributes 标志。

(继承自 Type)
GenericParameterPosition

获取声明参数的泛型类型或方法的类型参数列表中的类型参数的位置。

GenericTypeArguments

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GenericTypeArguments

获取此类型泛型类型参数的数组。

(继承自 Type)
GenericTypeArguments

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GenericTypeParameters

获取当前实例泛型类型参数的数组。

(继承自 TypeInfo)
GUID

不支持不完整的泛型类型参数。

HasElementType

获取一个值,通过该值指示当前 Type 是包含还是引用另一类型,即当前 Type 是数组、指针还是通过引用传递。

(继承自 Type)
HasElementType

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
ImplementedInterfaces

获取当前类型实现的接口的集合。

(继承自 TypeInfo)
IsAbstract

获取一个值,通过该值指示 Type 是否为抽象的并且必须被重写。

(继承自 Type)
IsAbstract

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsAnsiClass

获取一个值,该值指示是否为 AnsiClass 选择了字符串格式属性 Type

(继承自 Type)
IsAnsiClass

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsArray

获取一个值,该值指示类型是否为数组。

(继承自 Type)
IsArray

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsAutoClass

获取一个值,该值指示是否为 AutoClass 选择了字符串格式属性 Type

(继承自 Type)
IsAutoClass

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsAutoLayout

获取指示当前类型的字段是否由公共语言运行时自动放置的值。

(继承自 Type)
IsAutoLayout

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsByRef

获取一个值,该值指示 Type 是否由引用传递。

(继承自 Type)
IsByRef

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsByRefLike

获取一个值,该值指示类型是否是与 byref 类似的结构。

IsByRefLike

获取一个值,该值指示类型是否是与 byref 类似的结构。

(继承自 Type)
IsClass

获取一个值,通过该值指示 Type 是否是一个类或委托;即,不是值类型或接口。

(继承自 Type)
IsClass

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsCollectible

获取一个值,该值指示此 MemberInfo 对象是否是包含在可回收的 AssemblyLoadContext 中的程序集的一部分。

(继承自 MemberInfo)
IsCOMObject

获取一个值,通过该值指示 Type 是否为 COM 对象。

(继承自 Type)
IsCOMObject

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsConstructedGenericType

获取指示此对象是否表示构造的泛型类型的值。

IsConstructedGenericType

获取指示此对象是否表示构造的泛型类型的值。 你可以创建构造型泛型类型的实例。

(继承自 Type)
IsContextful

获取一个值,通过该值指示 Type 在上下文中是否可以被承载。

(继承自 Type)
IsEnum

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

IsEnum

获取一个值,该值指示当前的 Type 是否表示枚举。

(继承自 Type)
IsEnum

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsExplicitLayout

获取指示当前类型的字段是否放置在显式指定的偏移量处的值。

(继承自 Type)
IsExplicitLayout

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsFunctionPointer

获取一个值,该值指示当前 Type 是否为函数指针。

(继承自 Type)
IsGenericMethodParameter

获取一个值,该值指示当前 Type 是否表示泛型方法定义中的类型参数。

(继承自 Type)
IsGenericParameter

在所有情况下均获取 true

IsGenericType

在所有情况下均返回 false

IsGenericTypeDefinition

在所有情况下均获取 false

IsGenericTypeParameter

获取一个值,该值指示当前 Type 是否表示泛型类型定义中的类型参数。

(继承自 Type)
IsImport

获取一个值,该值指示 Type 是否应用了 ComImportAttribute 属性,如果应用了该属性,则表示它是从 COM 类型库导入的。

(继承自 Type)
IsImport

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsInterface

获取一个值,通过该值指示 Type 是否是一个接口;即,不是类或值类型。

(继承自 Type)
IsInterface

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsLayoutSequential

获取指示当前类型的字段是否按顺序(定义顺序或发送到元数据的顺序)放置的值。

(继承自 Type)
IsLayoutSequential

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsMarshalByRef

获取一个值,该值指示 Type 是否按引用进行封送。

(继承自 Type)
IsMarshalByRef

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNested

获取一个指示当前 Type 对象是否表示其定义嵌套在另一个类型的定义之内的类型的值。

(继承自 Type)
IsNested

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedAssembly

获取一个值,通过该值指示 Type 是否是嵌套的并且只能在它自己的程序集内可见。

(继承自 Type)
IsNestedAssembly

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedFamANDAssem

获取一个值,通过该值指示 Type 是否是嵌套的并且只对同时属于自己家族和自己程序集的类可见。

(继承自 Type)
IsNestedFamANDAssem

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedFamily

获取一个值,通过该值指示 Type 是否是嵌套的并且只能在它自己的家族内可见。

(继承自 Type)
IsNestedFamily

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedFamORAssem

获取一个值,通过该值指示 Type 是否是嵌套的并且只对属于它自己的家族或属于它自己的程序集的类可见。

(继承自 Type)
IsNestedFamORAssem

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedPrivate

获取一个值,通过该值指示 Type 是否是嵌套的并声明为私有。

(继承自 Type)
IsNestedPrivate

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNestedPublic

获取一个值,通过该值指示类是否是嵌套的并且声明为公共的。

(继承自 Type)
IsNestedPublic

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsNotPublic

获取一个值,该值指示 Type 是否声明为公共类型。

(继承自 Type)
IsNotPublic

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsPointer

获取一个值,通过该值指示 Type 是否为指针。

(继承自 Type)
IsPointer

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsPrimitive

获取一个值,通过该值指示 Type 是否为基元类型之一。

(继承自 Type)
IsPrimitive

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsPublic

获取一个值,该值指示 Type 是否声明为公共类型。

(继承自 Type)
IsPublic

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsSealed

获取一个值,该值指示 Type 是否声明为密封的。

(继承自 Type)
IsSealed

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsSecurityCritical

获取一个值,该值指示当前的类型在当前信任级别上是安全关键的还是安全可靠关键的,并因此可以执行关键操作。

(继承自 Type)
IsSecuritySafeCritical

获取一个值,该值指示当前类型在当前信任级别上是否是安全可靠关键的;即它是否可以执行关键操作并可以由透明代码访问。

(继承自 Type)
IsSecurityTransparent

获取一个值,该值指示当前类型在当前信任级别上是否是透明的而无法执行关键操作。

(继承自 Type)
IsSerializable

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

IsSerializable
已过时.

获取一个值, Type 该值指示 是否可进行二进制序列化。

(继承自 Type)
IsSerializable

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsSignatureType

获取一个值,该值指示类型是否是签名类型。

(继承自 Type)
IsSpecialName

获取一个值,该值指示该类型是否具有需要特殊处理的名称。

(继承自 Type)
IsSpecialName

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsSZArray

获取一个值,该值指示类型是否是仅可表示下限为零的一维数组的数组类型。

IsSZArray

获取一个值,该值指示类型是否是仅可表示下限为零的一维数组的数组类型。

(继承自 Type)
IsTypeDefinition

获取一个值,该值指示类型是否是类型定义。

IsTypeDefinition

获取一个值,该值指示类型是否是类型定义。

(继承自 Type)
IsUnicodeClass

获取一个值,该值指示是否为 UnicodeClass 选择了字符串格式属性 Type

(继承自 Type)
IsUnicodeClass

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsUnmanagedFunctionPointer

获取一个值,该值指示当前 Type 是否为非托管函数指针。

(继承自 Type)
IsValueType

获取一个值,通过该值指示 Type 是否为值类型。

(继承自 Type)
IsValueType

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsVariableBoundArray

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

IsVariableBoundArray

获取一个值,该值指示类型是否是可表示多维数组或具有任意下限的数组的数组类型。

(继承自 Type)
IsVisible

获取一个指示 Type 是否可由程序集之外的代码访问的值。

(继承自 Type)
IsVisible

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
MemberType

获取一个指示此成员是类型还是嵌套类型的 MemberTypes 值。

(继承自 Type)
MemberType

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
MetadataToken

获取一个标记,该标记用于标识元数据中的当前动态模块。

MetadataToken

获取一个值,该值标识元数据元素。

(继承自 MemberInfo)
Module

获取包含泛型类型参数的动态模块。

Name

获取泛型类型参数的名称。

Namespace

在所有情况下均获取 null

ReflectedType

获取用于获取 GenericTypeParameterBuilderType 对象。

ReflectedType

获取用于获取 MemberInfo 的此实例的类对象。

(继承自 MemberInfo)
StructLayoutAttribute

获取一个描述当前类型的布局的 StructLayoutAttribute

(继承自 Type)
StructLayoutAttribute

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
TypeHandle

不支持不完整的泛型类型参数。

TypeInitializer

获取该类型的初始值设定项。

(继承自 Type)
TypeInitializer

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
UnderlyingSystemType

获取当前泛型类型参数。

UnderlyingSystemType

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)

方法

AsType()

返回 Type 对象形式的当前类型。

(继承自 TypeInfo)
Equals(Object)

检测给定对象是否为 EventToken 的实例并且是否等于当前实例。

Equals(Type)

确定当前 Type 的基础系统类型是否与指定 Type 的基础系统类型相同。

(继承自 Type)
FindInterfaces(TypeFilter, Object)

返回表示接口(由当前 Type 所实现或继承)的筛选列表的 Type 对象数组。

(继承自 Type)
FindInterfaces(TypeFilter, Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
FindMembers(MemberTypes, BindingFlags, MemberFilter, Object)

返回指定成员类型的 MemberInfo 对象的筛选数组。

(继承自 Type)
FindMembers(MemberTypes, BindingFlags, MemberFilter, Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetArrayRank()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetArrayRank()

获取数组中的维数。

(继承自 Type)
GetArrayRank()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetAttributeFlagsImpl()

在派生类中重写时,实现 Attributes 属性,并获取枚举值的按位组合(它指示与 Type 关联的特性)。

GetAttributeFlagsImpl()

在派生类中重写时,实现 Attributes 属性,并获取枚举值的按位组合(它指示与 Type 关联的特性)。

(继承自 Type)
GetConstructor(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

用指定绑定约束和指定调用约定,搜索其参数与指定参数类型及修饰符匹配的构造函数。

(继承自 Type)
GetConstructor(BindingFlags, Binder, Type[], ParameterModifier[])

使用指定绑定约束搜索其参数与指定自变量类型和修饰符匹配的构造函数。

(继承自 Type)
GetConstructor(BindingFlags, Type[])

使用指定的绑定约束搜索其参数与指定参数类型匹配的构造函数。

(继承自 Type)
GetConstructor(Type[])

搜索其参数与指定数组中的类型匹配的公共实例构造函数。

(继承自 Type)
GetConstructor(Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

不支持不完整的泛型类型参数。

GetConstructorImpl(BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定的自变量类型和修饰符匹配的构造函数。

(继承自 Type)
GetConstructors()

返回为当前 Type 定义的所有公共构造函数。

(继承自 Type)
GetConstructors()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetConstructors(BindingFlags)

不支持不完整的泛型类型参数。

GetConstructors(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetCustomAttributes(Boolean)

不支持不完整的泛型类型参数。

GetCustomAttributes(Boolean)

在派生类中重写时,返回应用于此成员的所有自定义属性的数组。

(继承自 MemberInfo)
GetCustomAttributes(Type, Boolean)

不支持不完整的泛型类型参数。

GetCustomAttributes(Type, Boolean)

在派生类中重写时,返回应用于此成员并由 Type 标识的自定义属性的数组。

(继承自 MemberInfo)
GetCustomAttributesData()

返回 CustomAttributeData 对象列表,这些对象表示已应用到目标成员的特性相关数据。

(继承自 MemberInfo)
GetDeclaredEvent(String)

返回一个 对象,该对象表示由当前类型声明的指定事件。

(继承自 TypeInfo)
GetDeclaredField(String)

返回一个 对象,该对象表示由当前类型声明的指定字段。

(继承自 TypeInfo)
GetDeclaredMethod(String)

返回一个 对象,该对象表示由当前类型声明的指定方法。

(继承自 TypeInfo)
GetDeclaredMethods(String)

返回一个集合,该集合包含当前类型上声明的与指定名称匹配的所有方法。

(继承自 TypeInfo)
GetDeclaredNestedType(String)

返回一个 对象,该对象表示由当前类型声明的指定嵌套类型。

(继承自 TypeInfo)
GetDeclaredProperty(String)

返回一个 对象,该对象表示由当前类型声明的指定属性。

(继承自 TypeInfo)
GetDefaultMembers()

搜索为设置了 Type 的当前 DefaultMemberAttribute 定义的成员。

(继承自 Type)
GetDefaultMembers()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetElementType()

在所有情况下均引发 NotSupportedException

GetEnumName(Object)

返回当前枚举类型中具有指定值的常数的名称。

(继承自 Type)
GetEnumName(Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEnumNames()

返回当前枚举类型中各个成员的名称。

(继承自 Type)
GetEnumNames()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEnumUnderlyingType()

返回当前枚举类型的基础类型。

(继承自 Type)
GetEnumUnderlyingType()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEnumValues()

返回当前枚举类型中各个常数的值组成的数组。

(继承自 Type)
GetEnumValues()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEnumValuesAsUnderlyingType()

检索此枚举类型的基础类型常量的值数组。

(继承自 Type)
GetEvent(String)

返回表示指定的公共事件的 EventInfo 对象。

(继承自 Type)
GetEvent(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEvent(String, BindingFlags)

不支持不完整的泛型类型参数。

GetEvent(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEvents()

不支持不完整的泛型类型参数。

GetEvents()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetEvents(BindingFlags)

不支持不完整的泛型类型参数。

GetEvents(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetField(String)

搜索具有指定名称的公共字段。

(继承自 Type)
GetField(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetField(String, BindingFlags)

不支持不完整的泛型类型参数。

GetField(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetFields()

返回当前 Type 的所有公共字段。

(继承自 Type)
GetFields()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetFields(BindingFlags)

不支持不完整的泛型类型参数。

GetFields(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetFunctionPointerCallingConventions()

在派生类中重写时,返回当前函数指针 Type的调用约定。

(继承自 Type)
GetFunctionPointerParameterTypes()

在派生类中重写时,返回当前函数指针 Type的参数类型。

(继承自 Type)
GetFunctionPointerReturnType()

在派生类中重写时,返回当前函数指针 Type的返回类型。

(继承自 Type)
GetGenericArguments()

对泛型类型参数无效。

GetGenericArguments()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetGenericParameterConstraints()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetGenericParameterConstraints()

返回表示当前泛型类型参数约束的 Type 对象的数组。

(继承自 Type)
GetGenericParameterConstraints()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetGenericTypeDefinition()

对泛型类型参数无效。

GetHashCode()

返回当前实例的 32 位整数哈希代码。

GetInterface(String)

搜索具有指定名称的接口。

(继承自 Type)
GetInterface(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetInterface(String, Boolean)

不支持不完整的泛型类型参数。

GetInterface(String, Boolean)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetInterfaceMap(Type)

不支持不完整的泛型类型参数。

GetInterfaces()

不支持不完整的泛型类型参数。

GetInterfaces()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMember(String)

搜索具有指定名称的公共成员。

(继承自 Type)
GetMember(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMember(String, BindingFlags)

使用指定绑定约束搜索指定成员。

(继承自 Type)
GetMember(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMember(String, MemberTypes, BindingFlags)

不支持不完整的泛型类型参数。

GetMember(String, MemberTypes, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMembers()

返回为当前 Type 的所有公共成员。

(继承自 Type)
GetMembers()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMembers(BindingFlags)

不支持不完整的泛型类型参数。

GetMembers(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMemberWithSameMetadataDefinitionAs(MemberInfo)

MemberInfo在与指定的 MemberInfo匹配的当前 Type 上搜索 。

(继承自 Type)
GetMethod(String)

搜索具有指定名称的公共方法。

(继承自 Type)
GetMethod(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMethod(String, BindingFlags)

使用指定绑定约束搜索指定方法。

(继承自 Type)
GetMethod(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

用指定的绑定约束和指定的调用约定,搜索参数与指定的参数类型及修饰符相匹配的指定方法。

(继承自 Type)
GetMethod(String, BindingFlags, Binder, Type[], ParameterModifier[])

使用指定绑定约束,搜索其参数与指定自变量类型及修饰符匹配的指定方法。

(继承自 Type)
GetMethod(String, BindingFlags, Type[])

使用指定的绑定约束搜索其参数与指定参数类型匹配的指定方法。

(继承自 Type)
GetMethod(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

使用指定的绑定约束和指定的调用约定搜索其参数与指定泛型参数计数、参数类型及修饰符匹配的指定方法。

(继承自 Type)
GetMethod(String, Int32, BindingFlags, Binder, Type[], ParameterModifier[])

使用指定绑定约束,搜索其参数与指定泛型参数计数、参数类型及修饰符匹配的指定方法。

(继承自 Type)
GetMethod(String, Int32, BindingFlags, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 Type)
GetMethod(String, Int32, Type[])

搜索其参数与指定泛型参数计数及参数类型匹配的指定公共方法。

(继承自 Type)
GetMethod(String, Int32, Type[], ParameterModifier[])

搜索其参数与指定泛型参数计数、参数类型及修饰符匹配的指定公共方法。

(继承自 Type)
GetMethod(String, Type[])

搜索其参数与指定参数类型匹配的指定公共方法。

(继承自 Type)
GetMethod(String, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMethod(String, Type[], ParameterModifier[])

搜索其参数与指定参数类型及修饰符匹配的指定公共方法。

(继承自 Type)
GetMethod(String, Type[], ParameterModifier[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

不支持不完整的泛型类型参数。

GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定的自变量类型和修饰符匹配的指定方法。

(继承自 Type)
GetMethodImpl(String, Int32, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束和指定的调用约定搜索其参数与指定泛型参数计数、参数类型和修饰符匹配的指定方法。

(继承自 Type)
GetMethods()

返回为当前 Type 的所有公共方法。

(继承自 Type)
GetMethods()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetMethods(BindingFlags)

不支持不完整的泛型类型参数。

GetMethods(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetNestedType(String)

搜索具有指定名称的公共嵌套类型。

(继承自 Type)
GetNestedType(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetNestedType(String, BindingFlags)

不支持不完整的泛型类型参数。

GetNestedType(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetNestedTypes()

返回嵌套在当前的 Type 中的公共类型。

(继承自 Type)
GetNestedTypes()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetNestedTypes(BindingFlags)

不支持不完整的泛型类型参数。

GetNestedTypes(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetOptionalCustomModifiers()

在派生类中重写时,返回当前 Type的可选自定义修饰符。

(继承自 Type)
GetProperties()

返回为当前 Type 的所有公共属性。

(继承自 Type)
GetProperties()

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperties(BindingFlags)

不支持不完整的泛型类型参数。

GetProperties(BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String)

搜索具有指定名称的公共属性。

(继承自 Type)
GetProperty(String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String, BindingFlags)

使用指定的绑定约束搜索指定属性。

(继承自 Type)
GetProperty(String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])

使用指定的绑定约束,搜索参数与指定的自变量类型及修饰符匹配的指定属性。

(继承自 Type)
GetProperty(String, Type)

搜索具有指定名称和返回类型的公共属性。

(继承自 Type)
GetProperty(String, Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String, Type, Type[])

搜索其参数与指定自变量类型匹配的指定公共属性。

(继承自 Type)
GetProperty(String, Type, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String, Type, Type[], ParameterModifier[])

搜索其参数与指定自变量类型及修饰符匹配的指定公共属性。

(继承自 Type)
GetProperty(String, Type, Type[], ParameterModifier[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetProperty(String, Type[])

搜索其参数与指定自变量类型匹配的指定公共属性。

(继承自 Type)
GetProperty(String, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
GetPropertyImpl(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])

不支持不完整的泛型类型参数。

GetPropertyImpl(String, BindingFlags, Binder, Type, Type[], ParameterModifier[])

当在派生类中重写时,使用指定的绑定约束搜索其参数与指定的参数类型和修饰符匹配的指定属性。

(继承自 Type)
GetRequiredCustomModifiers()

在派生类中重写时,返回当前 Type所需的自定义修饰符。

(继承自 Type)
GetType()

获取当前 Type

(继承自 Type)
GetType()

发现成员的属性并提供对成员元数据的访问权限。

(继承自 MemberInfo)
GetTypeCodeImpl()

返回此 Type 实例的基础类型代码。

(继承自 Type)
HasElementTypeImpl()

当在派生类中重写时,实现 HasElementType 属性,确定当前 Type 是否包含另一类型或对其引用;即,当前 Type 是否是数组、指针或由引用传递。

HasElementTypeImpl()

当在派生类中重写时,实现 HasElementType 属性,确定当前 Type 是否包含另一类型或对其引用;即,当前 Type 是否是数组、指针或由引用传递。

(继承自 Type)
HasSameMetadataDefinitionAs(MemberInfo)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 MemberInfo)
InvokeMember(String, BindingFlags, Binder, Object, Object[])

使用指定的绑定约束并匹配指定的参数列表,调用指定成员。

(继承自 Type)
InvokeMember(String, BindingFlags, Binder, Object, Object[], CultureInfo)

使用指定的绑定约束和匹配的指定参数列表及区域性来调用指定成员。

(继承自 Type)
InvokeMember(String, BindingFlags, Binder, Object, Object[], ParameterModifier[], CultureInfo, String[])

不支持不完整的泛型类型参数。

IsArrayImpl()

在派生类中重写时,实现 IsArray 属性并确定 Type 是否为数组。

IsArrayImpl()

在派生类中重写时,实现 IsArray 属性并确定 Type 是否为数组。

(继承自 Type)
IsAssignableFrom(Type)

在所有情况下都会引发 NotSupportedException 异常。

IsAssignableFrom(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsAssignableFrom(TypeInfo)

在所有情况下都会引发 NotSupportedException 异常。

IsAssignableTo(Type)

确定当前类型是否可分配给指定 targetType 的变量。

(继承自 Type)
IsByRefImpl()

在派生类中重写时,实现 IsByRef 属性并确定Type 是否通过引用传递。

IsByRefImpl()

在派生类中重写时,实现 IsByRef 属性并确定Type 是否通过引用传递。

(继承自 Type)
IsCOMObjectImpl()

当在派生类中重写时,实现 IsCOMObject 属性并确定 Type 是否为 COM 对象。

IsCOMObjectImpl()

当在派生类中重写时,实现 IsCOMObject 属性并确定 Type 是否为 COM 对象。

(继承自 Type)
IsContextfulImpl()

实现 IsContextful 属性并确定 Type 在上下文中是否可以被承载。

(继承自 Type)
IsDefined(Type, Boolean)

不支持不完整的泛型类型参数。

IsDefined(Type, Boolean)

在派生类中重写时,指示是否将指定类型或其派生类型的一个或多个特性应用于此成员。

(继承自 MemberInfo)
IsEnumDefined(Object)

返回一个值,该值指示当前的枚举类型中是否存在指定的值。

(继承自 Type)
IsEnumDefined(Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsEquivalentTo(Type)

确定两个 COM 类型是否具有相同的标识,以及是否符合类型等效的条件。

(继承自 Type)
IsEquivalentTo(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsInstanceOfType(Object)

确定指定的对象是否是当前 Type 的实例。

(继承自 Type)
IsInstanceOfType(Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

(继承自 TypeInfo)
IsMarshalByRefImpl()

实现 IsMarshalByRef 属性并确定 Type 是否按引用来进行封送。

(继承自 Type)
IsPointerImpl()

在派生类中重写时,实现 IsPointer 属性并确定 Type 是否为指针。

IsPointerImpl()

在派生类中重写时,实现 IsPointer 属性并确定 Type 是否为指针。

(继承自 Type)
IsPrimitiveImpl()

在派生类中重写时,实现 IsPrimitive 属性并确定 Type 是否为基元类型之一。

IsPrimitiveImpl()

在派生类中重写时,实现 IsPrimitive 属性并确定 Type 是否为基元类型之一。

(继承自 Type)
IsSubclassOf(Type)

不支持不完整的泛型类型参数。

IsValueTypeImpl()

实现 IsValueType 属性并确定 Type 是否是值类型;即,它不是值类或接口。

IsValueTypeImpl()

实现 IsValueType 属性并确定 Type 是否是值类型;即,它不是值类或接口。

(继承自 Type)
MakeArrayType()

返回元素类型为泛型类型参数的一维数组的类型。

MakeArrayType(Int32)

返回其元素类型为泛型类型参数,并具有指定维度数的数组类型。

MakeByRefType()

返回一个 Type 对象,此对象在作为引用参数传递时表示当前的泛型类型参数。

MakeGenericType(Type[])

对于不完整的泛型类型参数无效。

MakePointerType()

返回表示指向当前泛型类型参数的指针的 Type 对象。

MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
SetBaseTypeConstraint(Type)

设置某类型必须继承的基类型,以替换为类型参数。

SetBaseTypeConstraintCore(Type)

在派生类中重写时,设置类型必须继承的基类型才能替换类型参数。

SetCustomAttribute(ConstructorInfo, Byte[])

使用指定的自定义属性 blob 设置自定义属性。

SetCustomAttribute(CustomAttributeBuilder)

使用自定义属性生成器设置自定义属性。

SetCustomAttributeCore(ConstructorInfo, ReadOnlySpan<Byte>)

在派生类中重写时,在此程序集上设置自定义属性。

SetGenericParameterAttributes(GenericParameterAttributes)

设置泛型参数的方差特征和特殊约束,例如无参数构造函数约束。

SetGenericParameterAttributesCore(GenericParameterAttributes)

在派生类中重写时,设置泛型参数的方差特征和特殊约束,例如无参数构造函数约束。

SetInterfaceConstraints(Type[])

设置一个类型必须实现的接口,以替换为类型参数。

SetInterfaceConstraintsCore(Type[])

在派生类中重写时,设置类型必须实现才能替换类型参数的接口。

ToString()

返回当前泛型类型参数的字符串表示形式。

显式接口实现

_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 MemberInfo)
_MemberInfo.GetType()

获取一个表示 MemberInfo 类的 Type 对象。

(继承自 MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 MemberInfo)
_Type.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。

(继承自 Type)
_Type.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Type)
_Type.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Type)
_Type.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Type)
ICustomAttributeProvider.GetCustomAttributes(Boolean)

返回在该成员上定义的所有自定义特性的数组(已命名的特性除外),如果没有自定义特性,则返回空数组。

(继承自 MemberInfo)
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

返回在该成员上定义、由类型标识的自定义属性数组,如果没有该类型的自定义属性,则返回空数组。

(继承自 MemberInfo)
ICustomAttributeProvider.IsDefined(Type, Boolean)

指示是否在该成员上定义了一个或多个 attributeType 实例。

(继承自 MemberInfo)
IReflectableType.GetTypeInfo()

返回当前类型为 TypeInfo 对象的表示形式。

(继承自 TypeInfo)

扩展方法

GetCustomAttribute(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义特性。

GetCustomAttribute(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义特性,并可选择检查该成员的上级。

GetCustomAttribute<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义特性。

GetCustomAttribute<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义特性,并可选择检查该成员的上级。

GetCustomAttributes(MemberInfo)

检索应用于指定成员的自定义特性集合。

GetCustomAttributes(MemberInfo, Boolean)

检索应用于指定成员的自定义特性集合,并可选择检查该成员的上级。

GetCustomAttributes(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义特性集合。

GetCustomAttributes(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义特性集合,并可选择检查该成员的上级。

GetCustomAttributes<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义特性集合。

GetCustomAttributes<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义特性集合,并可选择检查该成员的上级。

IsDefined(MemberInfo, Type)

确定是否将指定类型的任何自定义属性应用于指定的成员。

IsDefined(MemberInfo, Type, Boolean)

指示一个指定类型的自定义特性是否应用于一个指定的数字,并选择性地应用于其的上级。

GetTypeInfo(Type)

返回指定类型的 TypeInfo 表示形式。

GetMetadataToken(MemberInfo)

获取给定成员的元数据令牌(如果可用)。

HasMetadataToken(MemberInfo)

返回表示元数据令牌是否可用于指定的成员的值。

GetRuntimeEvent(Type, String)

检索一个表示指定事件的对象。

GetRuntimeEvents(Type)

检索表示指定类型定义的所有事件的集合。

GetRuntimeField(Type, String)

检索表示指定字段的对象。

GetRuntimeFields(Type)

检索表示指定类型定义的所有字段的集合。

GetRuntimeInterfaceMap(TypeInfo, Type)

返回指定类型和指定接口的接口映射。

GetRuntimeMethod(Type, String, Type[])

检索表示指定方法的对象。

GetRuntimeMethods(Type)

检索表示指定类型定义的所有方法的集合。

GetRuntimeProperties(Type)

检索表示指定类型定义的所有属性的集合。

GetRuntimeProperty(Type, String)

检索表示指定属性的对象。

GetConstructor(Type, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetConstructors(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetConstructors(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetDefaultMembers(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetEvent(Type, String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetEvent(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetEvents(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetEvents(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetField(Type, String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetField(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetFields(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetFields(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetGenericArguments(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetInterfaces(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMember(Type, String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMember(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMembers(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMembers(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMethod(Type, String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMethod(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMethod(Type, String, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMethods(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetMethods(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetNestedType(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetNestedTypes(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperties(Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperties(Type, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperty(Type, String)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperty(Type, String, BindingFlags)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperty(Type, String, Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

GetProperty(Type, String, Type, Type[])

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

IsAssignableFrom(Type, Type)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

IsInstanceOfType(Type, Object)

为动态定义的泛型类型和方法定义并创建泛型类型参数。 此类不能被继承。

适用于

另请参阅