ConstructorBuilder ConstructorBuilder ConstructorBuilder ConstructorBuilder Class

定义

定义并表示动态类的构造函数。Defines and represents a constructor of a dynamic class.

public ref class ConstructorBuilder sealed : System::Reflection::ConstructorInfo, System::Runtime::InteropServices::_ConstructorBuilder
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class ConstructorBuilder : System.Reflection.ConstructorInfo, System.Runtime.InteropServices._ConstructorBuilder
type ConstructorBuilder = class
    inherit ConstructorInfo
    interface _ConstructorBuilder
Public NotInheritable Class ConstructorBuilder
Inherits ConstructorInfo
Implements _ConstructorBuilder
继承
属性
实现

示例

以下代码示例显示的上下文用法ConstructorBuilderThe following code sample illustrates the contextual usage of a ConstructorBuilder.

using namespace System;
using namespace System::Threading;
using namespace System::Reflection;
using namespace System::Reflection::Emit;
Type^ DynamicPointTypeGen()
{
   Type^ pointType = nullptr;
   array<Type^>^temp0 = {int::typeid,int::typeid,int::typeid};
   array<Type^>^ctorParams = temp0;
   AppDomain^ myDomain = Thread::GetDomain();
   AssemblyName^ myAsmName = gcnew AssemblyName;
   myAsmName->Name = "MyDynamicAssembly";
   AssemblyBuilder^ myAsmBuilder = myDomain->DefineDynamicAssembly( myAsmName, AssemblyBuilderAccess::RunAndSave );
   ModuleBuilder^ pointModule = myAsmBuilder->DefineDynamicModule( "PointModule", "Point.dll" );
   TypeBuilder^ pointTypeBld = pointModule->DefineType( "Point", TypeAttributes::Public );
   FieldBuilder^ xField = pointTypeBld->DefineField( "x", int::typeid, FieldAttributes::Public );
   FieldBuilder^ yField = pointTypeBld->DefineField( "y", int::typeid, FieldAttributes::Public );
   FieldBuilder^ zField = pointTypeBld->DefineField( "z", int::typeid, FieldAttributes::Public );
   Type^ objType = Type::GetType( "System.Object" );
   ConstructorInfo^ objCtor = objType->GetConstructor( gcnew array<Type^>(0) );
   ConstructorBuilder^ pointCtor = pointTypeBld->DefineConstructor( MethodAttributes::Public, CallingConventions::Standard, ctorParams );
   ILGenerator^ ctorIL = pointCtor->GetILGenerator();
   
   // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
   // hold the actual passed parameters. ldarg.0 is used by instance methods
   // to hold a reference to the current calling bject instance. Static methods
   // do not use arg.0, since they are not instantiated and hence no reference
   // is needed to distinguish them.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   
   // Here, we wish to create an instance of System::Object by invoking its
   // constructor, as specified above.
   ctorIL->Emit( OpCodes::Call, objCtor );
   
   // Now, we'll load the current instance in arg 0, along
   // with the value of parameter "x" stored in arg 1, into stfld.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_1 );
   ctorIL->Emit( OpCodes::Stfld, xField );
   
   // Now, we store arg 2 "y" in the current instance with stfld.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_2 );
   ctorIL->Emit( OpCodes::Stfld, yField );
   
   // Last of all, arg 3 "z" gets stored in the current instance.
   ctorIL->Emit( OpCodes::Ldarg_0 );
   ctorIL->Emit( OpCodes::Ldarg_3 );
   ctorIL->Emit( OpCodes::Stfld, zField );
   
   // Our work complete, we return.
   ctorIL->Emit( OpCodes::Ret );
   
   // Now, let's create three very simple methods so we can see our fields.
   array<String^>^temp1 = {"GetX","GetY","GetZ"};
   array<String^>^mthdNames = temp1;
   System::Collections::IEnumerator^ myEnum = mthdNames->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      String^ mthdName = safe_cast<String^>(myEnum->Current);
      MethodBuilder^ getFieldMthd = pointTypeBld->DefineMethod( mthdName, MethodAttributes::Public, int::typeid, nullptr );
      ILGenerator^ mthdIL = getFieldMthd->GetILGenerator();
      mthdIL->Emit( OpCodes::Ldarg_0 );
      if ( mthdName->Equals( "GetX" ) )
            mthdIL->Emit( OpCodes::Ldfld, xField );
      else
      if ( mthdName->Equals( "GetY" ) )
            mthdIL->Emit( OpCodes::Ldfld, yField );
      else
      if ( mthdName->Equals( "GetZ" ) )
            mthdIL->Emit( OpCodes::Ldfld, zField );



      mthdIL->Emit( OpCodes::Ret );
   }

   pointType = pointTypeBld->CreateType();
   
   // Let's save it, just for posterity.
   myAsmBuilder->Save( "Point.dll" );
   return pointType;
}

int main()
{
   Type^ myDynamicType = nullptr;
   Object^ aPoint = nullptr;
   array<Type^>^temp2 = {int::typeid,int::typeid,int::typeid};
   array<Type^>^aPtypes = temp2;
   array<Object^>^temp3 = {4,5,6};
   array<Object^>^aPargs = temp3;
   
   // Call the  method to build our dynamic class.
   myDynamicType = DynamicPointTypeGen();
   Console::WriteLine( "Some information about my new Type '{0}':", myDynamicType->FullName );
   Console::WriteLine( "Assembly: '{0}'", myDynamicType->Assembly );
   Console::WriteLine( "Attributes: '{0}'", myDynamicType->Attributes );
   Console::WriteLine( "Module: '{0}'", myDynamicType->Module );
   Console::WriteLine( "Members: " );
   System::Collections::IEnumerator^ myEnum = myDynamicType->GetMembers()->GetEnumerator();
   while ( myEnum->MoveNext() )
   {
      MemberInfo^ member = safe_cast<MemberInfo^>(myEnum->Current);
      Console::WriteLine( "-- {0} {1};", member->MemberType, member->Name );
   }

   Console::WriteLine( "---" );
   
   // Let's take a look at the constructor we created.
   ConstructorInfo^ myDTctor = myDynamicType->GetConstructor( aPtypes );
   Console::WriteLine( "Constructor: {0};", myDTctor );
   Console::WriteLine( "---" );
   
   // Now, we get to use our dynamically-created class by invoking the constructor.
   aPoint = myDTctor->Invoke( aPargs );
   Console::WriteLine( "aPoint is type {0}.", aPoint->GetType() );
   
   // Finally, let's reflect on the instance of our new type - aPoint - and
   // make sure everything proceeded according to plan.
   Console::WriteLine( "aPoint.x = {0}", myDynamicType->InvokeMember( "GetX", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   Console::WriteLine( "aPoint.y = {0}", myDynamicType->InvokeMember( "GetY", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   Console::WriteLine( "aPoint.z = {0}", myDynamicType->InvokeMember( "GetZ", BindingFlags::InvokeMethod, nullptr, aPoint, gcnew array<Object^>(0) ) );
   
   // +++ OUTPUT +++
   // Some information about my new Type 'Point':
   // Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
   // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
   // Module: 'PointModule'
   // Members:
   // -- Field x;
   // -- Field y;
   // -- Field z;
   // -- Method GetHashCode;
   // -- Method Equals;
   // -- Method ToString;
   // -- Method GetType;
   // -- Constructor .ctor;
   // ---
   // Constructor: Void .ctor(Int32, Int32, Int32);
   // ---
   // aPoint is type Point.
   // aPoint.x = 4
   // aPoint.y = 5
   // aPoint.z = 6
}


using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;

class TestCtorBuilder {
 
  	public static Type DynamicPointTypeGen() {
	  
	   Type pointType = null;
	   Type[] ctorParams = new Type[] {typeof(int),
					    typeof(int),
					    typeof(int)};
 	
	   AppDomain myDomain = Thread.GetDomain();
	   AssemblyName myAsmName = new AssemblyName();
	   myAsmName.Name = "MyDynamicAssembly";
	
	   AssemblyBuilder myAsmBuilder = myDomain.DefineDynamicAssembly(
					  myAsmName, 
					  AssemblyBuilderAccess.RunAndSave);

   	   ModuleBuilder pointModule = myAsmBuilder.DefineDynamicModule("PointModule",
									"Point.dll");

	   TypeBuilder pointTypeBld = pointModule.DefineType("Point",
						              TypeAttributes.Public);

	   FieldBuilder xField = pointTypeBld.DefineField("x", typeof(int),
                                                          FieldAttributes.Public);
	   FieldBuilder yField = pointTypeBld.DefineField("y", typeof(int), 
                                                          FieldAttributes.Public);
	   FieldBuilder zField = pointTypeBld.DefineField("z", typeof(int),
                                                          FieldAttributes.Public);


           Type objType = Type.GetType("System.Object"); 
           ConstructorInfo objCtor = objType.GetConstructor(new Type[0]);

	   ConstructorBuilder pointCtor = pointTypeBld.DefineConstructor(
					  MethodAttributes.Public,
					  CallingConventions.Standard,
					  ctorParams);
	   ILGenerator ctorIL = pointCtor.GetILGenerator();

	   // NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
	   // hold the actual passed parameters. ldarg.0 is used by instance methods
	   // to hold a reference to the current calling object instance. Static methods
	   // do not use arg.0, since they are not instantiated and hence no reference
	   // is needed to distinguish them. 

           ctorIL.Emit(OpCodes.Ldarg_0);

	   // Here, we wish to create an instance of System.Object by invoking its
  	   // constructor, as specified above.

           ctorIL.Emit(OpCodes.Call, objCtor);

	   // Now, we'll load the current instance ref in arg 0, along
	   // with the value of parameter "x" stored in arg 1, into stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_1);
           ctorIL.Emit(OpCodes.Stfld, xField); 

	   // Now, we store arg 2 "y" in the current instance with stfld.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_2);
           ctorIL.Emit(OpCodes.Stfld, yField); 

	   // Last of all, arg 3 "z" gets stored in the current instance.

           ctorIL.Emit(OpCodes.Ldarg_0);
           ctorIL.Emit(OpCodes.Ldarg_3);
           ctorIL.Emit(OpCodes.Stfld, zField); 
           
           // Our work complete, we return.

	   ctorIL.Emit(OpCodes.Ret); 

	   // Now, let's create three very simple methods so we can see our fields.

	   string[] mthdNames = new string[] {"GetX", "GetY", "GetZ"}; 

           foreach (string mthdName in mthdNames) {
              MethodBuilder getFieldMthd = pointTypeBld.DefineMethod(
				           mthdName, 
				           MethodAttributes.Public,
                                           typeof(int), 
                                           null);
	      ILGenerator mthdIL = getFieldMthd.GetILGenerator();
	   
	      mthdIL.Emit(OpCodes.Ldarg_0);
  	      switch (mthdName) {
	         case "GetX": mthdIL.Emit(OpCodes.Ldfld, xField);
			      break;
	         case "GetY": mthdIL.Emit(OpCodes.Ldfld, yField);
			      break;
	         case "GetZ": mthdIL.Emit(OpCodes.Ldfld, zField);
			      break;

	      }
	      mthdIL.Emit(OpCodes.Ret);

           }
	   // Finally, we create the type.

 	   pointType = pointTypeBld.CreateType();

	   // Let's save it, just for posterity.
	   
	   myAsmBuilder.Save("Point.dll");
	
	   return pointType;

 	}

	public static void Main() {
	
	   Type myDynamicType = null;
           object aPoint = null;
	   Type[] aPtypes = new Type[] {typeof(int), typeof(int), typeof(int)};
           object[] aPargs = new object[] {4, 5, 6};
	
	   // Call the  method to build our dynamic class.

	   myDynamicType = DynamicPointTypeGen();

	   Console.WriteLine("Some information about my new Type '{0}':",
			      myDynamicType.FullName);
	   Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly);
	   Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes);
	   Console.WriteLine("Module: '{0}'", myDynamicType.Module);
	   Console.WriteLine("Members: "); 
	   foreach (MemberInfo member in myDynamicType.GetMembers()) {
		Console.WriteLine("-- {0} {1};", member.MemberType, member.Name);
	   }

           Console.WriteLine("---");

	   // Let's take a look at the constructor we created.

	   ConstructorInfo myDTctor = myDynamicType.GetConstructor(aPtypes);
           Console.WriteLine("Constructor: {0};", myDTctor.ToString());

           Console.WriteLine("---");
	  
           // Now, we get to use our dynamically-created class by invoking the constructor. 

	   aPoint = myDTctor.Invoke(aPargs);
           Console.WriteLine("aPoint is type {0}.", aPoint.GetType());
	   	   

	   // Finally, let's reflect on the instance of our new type - aPoint - and
	   // make sure everything proceeded according to plan.

	   Console.WriteLine("aPoint.x = {0}",
			     myDynamicType.InvokeMember("GetX",
						        BindingFlags.InvokeMethod,
							null,
							aPoint,
							new object[0]));
	   Console.WriteLine("aPoint.y = {0}",
			     myDynamicType.InvokeMember("GetY",
						        BindingFlags.InvokeMethod,
							null,
							aPoint,
							new object[0]));
	   Console.WriteLine("aPoint.z = {0}",
			     myDynamicType.InvokeMember("GetZ",
						        BindingFlags.InvokeMethod,
							null,
							aPoint,
							new object[0]));

	    

	   // +++ OUTPUT +++
	   // Some information about my new Type 'Point':
	   // Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
	   // Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
	   // Module: 'PointModule'
	   // Members: 
	   // -- Field x;
	   // -- Field y;
	   // -- Field z;
           // -- Method GetHashCode;
           // -- Method Equals;
           // -- Method ToString;
           // -- Method GetType;
           // -- Constructor .ctor;
	   // ---
	   // Constructor: Void .ctor(Int32, Int32, Int32);
	   // ---
	   // aPoint is type Point.
	   // aPoint.x = 4
	   // aPoint.y = 5
	   // aPoint.z = 6
	    
	}
    
}


Imports System
Imports System.Threading
Imports System.Reflection
Imports System.Reflection.Emit

 _

Class TestCtorBuilder
   
   
   Public Shared Function DynamicPointTypeGen() As Type
      
      Dim pointType As Type = Nothing
      Dim ctorParams() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      
      Dim myDomain As AppDomain = Thread.GetDomain()
      Dim myAsmName As New AssemblyName()
      myAsmName.Name = "MyDynamicAssembly"
      
      Dim myAsmBuilder As AssemblyBuilder = myDomain.DefineDynamicAssembly(myAsmName, AssemblyBuilderAccess.RunAndSave)
      
      Dim pointModule As ModuleBuilder = myAsmBuilder.DefineDynamicModule("PointModule", "Point.dll")
      
      Dim pointTypeBld As TypeBuilder = pointModule.DefineType("Point", TypeAttributes.Public)
      
      Dim xField As FieldBuilder = pointTypeBld.DefineField("x", GetType(Integer), FieldAttributes.Public)
      Dim yField As FieldBuilder = pointTypeBld.DefineField("y", GetType(Integer), FieldAttributes.Public)
      Dim zField As FieldBuilder = pointTypeBld.DefineField("z", GetType(Integer), FieldAttributes.Public)
      
      Dim objType As Type = Type.GetType("System.Object")
      Dim objCtor As ConstructorInfo = objType.GetConstructor(New Type() {})
      
      Dim pointCtor As ConstructorBuilder = pointTypeBld.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, ctorParams)
      Dim ctorIL As ILGenerator = pointCtor.GetILGenerator()
      
      ' NOTE: ldarg.0 holds the "this" reference - ldarg.1, ldarg.2, and ldarg.3
      ' hold the actual passed parameters. ldarg.0 is used by instance methods
      ' to hold a reference to the current calling object instance. Static methods
      ' do not use arg.0, since they are not instantiated and hence no reference
      ' is needed to distinguish them. 
      ctorIL.Emit(OpCodes.Ldarg_0)
      
      ' Here, we wish to create an instance of System.Object by invoking its
      ' constructor, as specified above.
      ctorIL.Emit(OpCodes.Call, objCtor)
      
      ' Now, we'll load the current instance ref in arg 0, along
      ' with the value of parameter "x" stored in arg 1, into stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_1)
      ctorIL.Emit(OpCodes.Stfld, xField)
      
      ' Now, we store arg 2 "y" in the current instance with stfld.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_2)
      ctorIL.Emit(OpCodes.Stfld, yField)
      
      ' Last of all, arg 3 "z" gets stored in the current instance.
      ctorIL.Emit(OpCodes.Ldarg_0)
      ctorIL.Emit(OpCodes.Ldarg_3)
      ctorIL.Emit(OpCodes.Stfld, zField)
      
      ' Our work complete, we return.
      ctorIL.Emit(OpCodes.Ret)
      
      ' Now, let's create three very simple methods so we can see our fields.
      Dim mthdNames() As String = {"GetX", "GetY", "GetZ"}
      
      Dim mthdName As String
      For Each mthdName In  mthdNames
         Dim getFieldMthd As MethodBuilder = pointTypeBld.DefineMethod(mthdName, MethodAttributes.Public, GetType(Integer), Nothing)
         Dim mthdIL As ILGenerator = getFieldMthd.GetILGenerator()
         
         mthdIL.Emit(OpCodes.Ldarg_0)
         Select Case mthdName
            Case "GetX"
               mthdIL.Emit(OpCodes.Ldfld, xField)
            Case "GetY"
               mthdIL.Emit(OpCodes.Ldfld, yField)
            Case "GetZ"
               mthdIL.Emit(OpCodes.Ldfld, zField)
         End Select
         
         mthdIL.Emit(OpCodes.Ret)
      Next mthdName 
      ' Finally, we create the type.
      pointType = pointTypeBld.CreateType()
      
      ' Let's save it, just for posterity.
      myAsmBuilder.Save("Point.dll")
      
      Return pointType
   End Function 'DynamicPointTypeGen
    
   
   Public Shared Sub Main()
      
      Dim myDynamicType As Type = Nothing
      Dim aPoint As Object = Nothing
      Dim aPtypes() As Type = {GetType(Integer), GetType(Integer), GetType(Integer)}
      Dim aPargs() As Object = {4, 5, 6}
      
      ' Call the  method to build our dynamic class.
      myDynamicType = DynamicPointTypeGen()
      
      Console.WriteLine("Some information about my new Type '{0}':", myDynamicType.FullName)
      Console.WriteLine("Assembly: '{0}'", myDynamicType.Assembly)
      Console.WriteLine("Attributes: '{0}'", myDynamicType.Attributes)
      Console.WriteLine("Module: '{0}'", myDynamicType.Module)
      Console.WriteLine("Members: ")
      Dim member As MemberInfo
      For Each member In  myDynamicType.GetMembers()
         Console.WriteLine("-- {0} {1};", member.MemberType, member.Name)
      Next member
      
      Console.WriteLine("---")
      
      ' Let's take a look at the constructor we created.
      Dim myDTctor As ConstructorInfo = myDynamicType.GetConstructor(aPtypes)
      Console.WriteLine("Constructor: {0};", myDTctor.ToString())
      
      Console.WriteLine("---")
      
      ' Now, we get to use our dynamically-created class by invoking the constructor. 
      aPoint = myDTctor.Invoke(aPargs)
      Console.WriteLine("aPoint is type {0}.", aPoint.GetType())
      
      
      ' Finally, let's reflect on the instance of our new type - aPoint - and
      ' make sure everything proceeded according to plan.
      Console.WriteLine("aPoint.x = {0}", myDynamicType.InvokeMember("GetX", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.y = {0}", myDynamicType.InvokeMember("GetY", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
      Console.WriteLine("aPoint.z = {0}", myDynamicType.InvokeMember("GetZ", BindingFlags.InvokeMethod, Nothing, aPoint, New Object() {}))
   End Sub 'Main
End Class 'TestCtorBuilder



' +++ OUTPUT +++
' Some information about my new Type 'Point':
' Assembly: 'MyDynamicAssembly, Version=0.0.0.0'
' Attributes: 'AutoLayout, AnsiClass, NotPublic, Public'
' Module: 'PointModule'
' Members: 
' -- Field x;
' -- Field y;
' -- Field z;
' -- Method GetHashCode;
' -- Method Equals;
' -- Method ToString;
' -- Method GetType;
' -- Constructor .ctor;
' ---
' Constructor: Void .ctor(Int32, Int32, Int32);
' ---
' aPoint is type Point.
' aPoint.x = 4
' aPoint.y = 5
' aPoint.z = 6

注解

ConstructorBuilder 用于完全描述 Microsoft 中间语言 (MSIL) 中的构造函数包括名称、 属性、 签名和构造函数主体。ConstructorBuilder is used to fully describe a constructor in Microsoft intermediate language (MSIL), including the name, attributes, signature, and constructor body. 结合使用TypeBuilder类,以在运行时创建的类。It is used in conjunction with the TypeBuilder class to create classes at run time. 调用DefineConstructor若要获取的实例ConstructorBuilderCall DefineConstructor to get an instance of ConstructorBuilder.

如果为动态类型未定义构造函数,自动提供默认构造函数并调用基类的默认构造函数。If you do not define a constructor for your dynamic type, a default constructor is provided automatically, and it calls the default constructor of the base class.

如果使用ConstructorBuilder定义为动态类型的构造函数,默认构造函数未提供。If you use ConstructorBuilder to define a constructor for your dynamic type, a default constructor is not provided. 必须提供默认构造函数,除了你定义的构造函数的以下选项:You have the following options for providing a default constructor in addition to the constructor you defined:

  • 如果您希望只需调用类的基类的默认构造函数的默认构造函数,则可以使用TypeBuilder.DefineDefaultConstructor方法创建一个 (并根据需要限制对它的访问权限)。If you want a default constructor that simply calls the default constructor of the base class, you can use the TypeBuilder.DefineDefaultConstructor method to create one (and optionally restrict access to it). 不提供此默认构造函数的实现。Do not provide an implementation for this default constructor. 如果这样做,当您尝试使用构造函数是引发异常。If you do, an exception is thrown when you try to use the constructor. 不会引发异常时TypeBuilder.CreateType调用方法。No exception is thrown when the TypeBuilder.CreateType method is called.

  • 如果希望默认构造函数来执行多个只需调用基类的默认构造函数或调用另一个构造函数的基类,或执行其他操作完全,则必须使用TypeBuilder.DefineConstructor方法来创建ConstructorBuilder,并提供您自己的实现。If you want a default constructor that does something more than simply calling the default constructor of the base class, or that calls another constructor of the base class, or that does something else entirely, you must use the TypeBuilder.DefineConstructor method to create a ConstructorBuilder, and provide your own implementation.

属性

Attributes Attributes Attributes Attributes

获取此构造函数的属性。Gets the attributes for this constructor.

CallingConvention CallingConvention CallingConvention CallingConvention

获取一个 CallingConventions 值,该值取决于声明类型是否为泛型。Gets a CallingConventions value that depends on whether the declaring type is generic.

ContainsGenericParameters ContainsGenericParameters ContainsGenericParameters ContainsGenericParameters

获取一个值,该值指示泛型方法是否包含未赋值的泛型类型参数。Gets a value indicating whether the generic method contains unassigned generic type parameters.

(Inherited from MethodBase)
CustomAttributes CustomAttributes CustomAttributes CustomAttributes

获取包含此成员自定义属性的集合。Gets a collection that contains this member's custom attributes.

(Inherited from MemberInfo)
DeclaringType DeclaringType DeclaringType DeclaringType

获取对声明此成员的类型的 Type 对象的引用。Gets a reference to the Type object for the type that declares this member.

InitLocals InitLocals InitLocals InitLocals

获取或设置此构造函数中的局部变量是否应初始化为零。Gets or sets whether the local variables in this constructor should be zero-initialized.

IsAbstract IsAbstract IsAbstract IsAbstract

获取一个值,该值指示此方法是否为抽象方法。Gets a value indicating whether the method is abstract.

(Inherited from MethodBase)
IsAssembly IsAssembly IsAssembly IsAssembly

获取一个值,该值指示此方法或构造函数的潜在可见性是否由 Assembly 描述;也就是说,此方法或构造函数只对同一程序集中的其他类型可见,而对该程序集以外的派生类型则不可见。Gets a value indicating whether the potential visibility of this method or constructor is described by Assembly; that is, the method or constructor is visible at most to other types in the same assembly, and is not visible to derived types outside the assembly.

(Inherited from MethodBase)
IsCollectible IsCollectible IsCollectible IsCollectible

获取一个值,该值指示此 MemberInfo 对象是否是包含在可回收的 AssemblyLoadContext 中的程序集的一部分。Gets a value that indicates whether this MemberInfo object is part of an assembly held in a collectible AssemblyLoadContext.

(Inherited from MemberInfo)
IsConstructedGenericMethod IsConstructedGenericMethod IsConstructedGenericMethod IsConstructedGenericMethod Inherited from MethodBase
IsConstructor IsConstructor IsConstructor IsConstructor

获取一个值,该值指示此方法是否为构造函数。Gets a value indicating whether the method is a constructor.

(Inherited from MethodBase)
IsFamily IsFamily IsFamily IsFamily

获取一个值,该值指示此方法或构造函数的可见性是否由 Family 描述;也就是说,此方法或构造函数仅在其类和派生类内可见。Gets a value indicating whether the visibility of this method or constructor is described by Family; that is, the method or constructor is visible only within its class and derived classes.

(Inherited from MethodBase)
IsFamilyAndAssembly IsFamilyAndAssembly IsFamilyAndAssembly IsFamilyAndAssembly

获取一个值,该值指示此方法或构造函数的可见性是否由 FamANDAssem 描述;也就是说,此方法或构造函数可由派生类调用,但仅当这些派生类在同一程序集中时。Gets a value indicating whether the visibility of this method or constructor is described by FamANDAssem; that is, the method or constructor can be called by derived classes, but only if they are in the same assembly.

(Inherited from MethodBase)
IsFamilyOrAssembly IsFamilyOrAssembly IsFamilyOrAssembly IsFamilyOrAssembly

获取一个值,该值指示此方法或构造函数的潜在可见性是否由 FamORAssem 描述;也就是说,此方法或构造函数可由派生类(无论其位置如何)和同一程序集中的类调用。Gets a value indicating whether the potential visibility of this method or constructor is described by FamORAssem; that is, the method or constructor can be called by derived classes wherever they are, and by classes in the same assembly.

(Inherited from MethodBase)
IsFinal IsFinal IsFinal IsFinal

获取一个值,该值指示此方法是否为 finalGets a value indicating whether this method is final.

(Inherited from MethodBase)
IsGenericMethod IsGenericMethod IsGenericMethod IsGenericMethod

获取一个值,该值指示方法是否为泛型方法。Gets a value indicating whether the method is generic.

(Inherited from MethodBase)
IsGenericMethodDefinition IsGenericMethodDefinition IsGenericMethodDefinition IsGenericMethodDefinition

获取一个值,该值指示方法是否为泛型方法定义。Gets a value indicating whether the method is a generic method definition.

(Inherited from MethodBase)
IsHideBySig IsHideBySig IsHideBySig IsHideBySig

获取一个值,该值指示是否只有一个签名完全相同的同一种类的成员在派生类中是隐藏的。Gets a value indicating whether only a member of the same kind with exactly the same signature is hidden in the derived class.

(Inherited from MethodBase)
IsPrivate IsPrivate IsPrivate IsPrivate

获取一个值,该值指示此成员是否是私有的。Gets a value indicating whether this member is private.

(Inherited from MethodBase)
IsPublic IsPublic IsPublic IsPublic

获取一个值,该值指示这是否是一个公共方法。Gets a value indicating whether this is a public method.

(Inherited from MethodBase)
IsSecurityCritical IsSecurityCritical IsSecurityCritical IsSecurityCritical

获取一个值,该值指示当前方法或构造函数在当前信任级别上是安全关键的还是安全可靠关键的,因此可以执行关键操作。Gets a value that indicates whether the current method or constructor is security-critical or security-safe-critical at the current trust level, and therefore can perform critical operations.

(Inherited from MethodBase)
IsSecuritySafeCritical IsSecuritySafeCritical IsSecuritySafeCritical IsSecuritySafeCritical

获取一个值,该值指示当前方法或构造函数在当前信任级别上是安全可靠关键的;即它是否可以执行关键操作并可以由透明代码访问。Gets a value that indicates whether the current method or constructor is security-safe-critical at the current trust level; that is, whether it can perform critical operations and can be accessed by transparent code.

(Inherited from MethodBase)
IsSecurityTransparent IsSecurityTransparent IsSecurityTransparent IsSecurityTransparent

获取一个值,该值指示当前方法或构造函数在当前信任级别上是透明的,因此无法执行关键操作。Gets a value that indicates whether the current method or constructor is transparent at the current trust level, and therefore cannot perform critical operations.

(Inherited from MethodBase)
IsSpecialName IsSpecialName IsSpecialName IsSpecialName

获取一个值,该值指示此方法是否具有特殊名称。Gets a value indicating whether this method has a special name.

(Inherited from MethodBase)
IsStatic IsStatic IsStatic IsStatic

获取一个值,该值指示方法是否为 staticGets a value indicating whether the method is static.

(Inherited from MethodBase)
IsVirtual IsVirtual IsVirtual IsVirtual

获取一个值,该值指示方法是否为 virtualGets a value indicating whether the method is virtual.

(Inherited from MethodBase)
MemberType MemberType MemberType MemberType

获取 MemberTypes 值,该值指示此成员是构造函数。Gets a MemberTypes value indicating that this member is a constructor.

(Inherited from ConstructorInfo)
MetadataToken MetadataToken MetadataToken MetadataToken

获取一个值,该值标识元数据元素。Gets a value that identifies a metadata element.

(Inherited from MemberInfo)
MethodHandle MethodHandle MethodHandle MethodHandle

获取此方法的内部句柄。Gets the internal handle for the method. 使用此句柄访问基础元数据句柄。Use this handle to access the underlying metadata handle.

MethodImplementationFlags MethodImplementationFlags MethodImplementationFlags MethodImplementationFlags

获取指定方法实现特性的 MethodImplAttributes 标志。Gets the MethodImplAttributes flags that specify the attributes of a method implementation.

Module Module Module Module

获取定义此构造函数的动态模块。Gets the dynamic module in which this constructor is defined.

Name Name Name Name

检索此构造函数的名称。Retrieves the name of this constructor.

ReflectedType ReflectedType ReflectedType ReflectedType

保存对从中获取该对象的 Type 对象的引用。Holds a reference to the Type object from which this object was obtained.

ReturnType ReturnType ReturnType ReturnType

获取 nullGets null.

Signature Signature Signature Signature

检索字符串形式的字段的签名。Retrieves the signature of the field in the form of a string.

_MethodBase.IsAbstract _MethodBase.IsAbstract _MethodBase.IsAbstract _MethodBase.IsAbstract

有关此成员的说明,请参见 IsAbstractFor a description of this member, see IsAbstract.

(Inherited from MethodBase)
_MethodBase.IsAssembly _MethodBase.IsAssembly _MethodBase.IsAssembly _MethodBase.IsAssembly

有关此成员的说明,请参见 IsAssemblyFor a description of this member, see IsAssembly.

(Inherited from MethodBase)
_MethodBase.IsConstructor _MethodBase.IsConstructor _MethodBase.IsConstructor _MethodBase.IsConstructor

有关此成员的说明,请参见 IsConstructorFor a description of this member, see IsConstructor.

(Inherited from MethodBase)
_MethodBase.IsFamily _MethodBase.IsFamily _MethodBase.IsFamily _MethodBase.IsFamily

有关此成员的说明,请参见 IsFamilyFor a description of this member, see IsFamily.

(Inherited from MethodBase)
_MethodBase.IsFamilyAndAssembly _MethodBase.IsFamilyAndAssembly _MethodBase.IsFamilyAndAssembly _MethodBase.IsFamilyAndAssembly

有关此成员的说明,请参见 IsFamilyAndAssemblyFor a description of this member, see IsFamilyAndAssembly.

(Inherited from MethodBase)
_MethodBase.IsFamilyOrAssembly _MethodBase.IsFamilyOrAssembly _MethodBase.IsFamilyOrAssembly _MethodBase.IsFamilyOrAssembly

有关此成员的说明,请参见 IsFamilyOrAssemblyFor a description of this member, see IsFamilyOrAssembly.

(Inherited from MethodBase)
_MethodBase.IsFinal _MethodBase.IsFinal _MethodBase.IsFinal _MethodBase.IsFinal

有关此成员的说明,请参见 IsFinalFor a description of this member, see IsFinal.

(Inherited from MethodBase)
_MethodBase.IsHideBySig _MethodBase.IsHideBySig _MethodBase.IsHideBySig _MethodBase.IsHideBySig

有关此成员的说明,请参见 IsHideBySigFor a description of this member, see IsHideBySig.

(Inherited from MethodBase)
_MethodBase.IsPrivate _MethodBase.IsPrivate _MethodBase.IsPrivate _MethodBase.IsPrivate

有关此成员的说明,请参见 IsPrivateFor a description of this member, see IsPrivate.

(Inherited from MethodBase)
_MethodBase.IsPublic _MethodBase.IsPublic _MethodBase.IsPublic _MethodBase.IsPublic

有关此成员的说明,请参见 IsPublicFor a description of this member, see IsPublic.

(Inherited from MethodBase)
_MethodBase.IsSpecialName _MethodBase.IsSpecialName _MethodBase.IsSpecialName _MethodBase.IsSpecialName

有关此成员的说明,请参见 IsSpecialNameFor a description of this member, see IsSpecialName.

(Inherited from MethodBase)
_MethodBase.IsStatic _MethodBase.IsStatic _MethodBase.IsStatic _MethodBase.IsStatic

有关此成员的说明,请参见 IsStaticFor a description of this member, see IsStatic.

(Inherited from MethodBase)
_MethodBase.IsVirtual _MethodBase.IsVirtual _MethodBase.IsVirtual _MethodBase.IsVirtual

有关此成员的说明,请参见 IsVirtualFor a description of this member, see IsVirtual.

(Inherited from MethodBase)

方法

AddDeclarativeSecurity(SecurityAction, PermissionSet) AddDeclarativeSecurity(SecurityAction, PermissionSet) AddDeclarativeSecurity(SecurityAction, PermissionSet) AddDeclarativeSecurity(SecurityAction, PermissionSet)

向此构造函数添加声明性安全。Adds declarative security to this constructor.

DefineParameter(Int32, ParameterAttributes, String) DefineParameter(Int32, ParameterAttributes, String) DefineParameter(Int32, ParameterAttributes, String) DefineParameter(Int32, ParameterAttributes, String)

定义此构造函数的参数。Defines a parameter of this constructor.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from ConstructorInfo)
GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean) GetCustomAttributes(Boolean)

返回为此构造函数定义的所有自定义属性。Returns all the custom attributes defined for this constructor.

GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean) GetCustomAttributes(Type, Boolean)

返回由给定类型标识的自定义属性。Returns the custom attributes identified by the given type.

GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData() GetCustomAttributesData()

返回 CustomAttributeData 对象列表,这些对象表示已应用到目标成员的特性相关数据。Returns a list of CustomAttributeData objects representing data about the attributes that have been applied to the target member.

(Inherited from MemberInfo)
GetGenericArguments() GetGenericArguments() GetGenericArguments() GetGenericArguments()

返回 Type 对象的数组,这些对象表示泛型方法的类型实参或泛型方法定义的类型形参。Returns an array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition.

(Inherited from MethodBase)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from ConstructorInfo)
GetILGenerator() GetILGenerator() GetILGenerator() GetILGenerator()

获取此构造函数的 ILGeneratorGets an ILGenerator for this constructor.

GetILGenerator(Int32) GetILGenerator(Int32) GetILGenerator(Int32) GetILGenerator(Int32)

获取有指定 MSIL 流大小的 ILGenerator 对象,它可以用来生成此构造函数的方法体。Gets an ILGenerator object, with the specified MSIL stream size, that can be used to build a method body for this constructor.

GetMethodBody() GetMethodBody() GetMethodBody() GetMethodBody()

在派生类中重写后,获取 MethodBody 对象,该对象提供对 MSIL 流、局部变量和当前方法的异常的访问。When overridden in a derived class, gets a MethodBody object that provides access to the MSIL stream, local variables, and exceptions for the current method.

(Inherited from MethodBase)
GetMethodImplementationFlags() GetMethodImplementationFlags() GetMethodImplementationFlags() GetMethodImplementationFlags()

返回此构造函数的方法实现标志。Returns the method implementation flags for this constructor.

GetModule() GetModule() GetModule() GetModule()

返回对包含此构造函数的模块的引用。Returns a reference to the module that contains this constructor.

GetParameters() GetParameters() GetParameters() GetParameters()

返回此构造函数的参数。Returns the parameters of this constructor.

GetToken() GetToken() GetToken() GetToken()

返回表示此构造函数的标记的 MethodTokenReturns the MethodToken that represents the token for this constructor.

GetType() GetType() GetType() GetType() Inherited from ConstructorInfo
HasSameMetadataDefinitionAs(MemberInfo) HasSameMetadataDefinitionAs(MemberInfo) HasSameMetadataDefinitionAs(MemberInfo) HasSameMetadataDefinitionAs(MemberInfo) Inherited from MemberInfo
Invoke(BindingFlags, Binder, Object[], CultureInfo) Invoke(BindingFlags, Binder, Object[], CultureInfo) Invoke(BindingFlags, Binder, Object[], CultureInfo) Invoke(BindingFlags, Binder, Object[], CultureInfo)

动态调用由给定对象上的此实例所表示的构造函数,一并传递指定的参数,并受给定绑定器的约束。Dynamically invokes the constructor represented by this instance on the given object, passing along the specified parameters, and under the constraints of the given binder.

Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)

在指定 Binder 的约束下,用指定的参数动态调用此实例反映的构造函数。Dynamically invokes the constructor reflected by this instance with the specified arguments, under the constraints of the specified Binder.

Invoke(Object, Object[]) Invoke(Object, Object[]) Invoke(Object, Object[]) Invoke(Object, Object[])

使用指定参数调用由当前实例表示的方法或构造函数。Invokes the method or constructor represented by the current instance, using the specified parameters.

(Inherited from MethodBase)
Invoke(Object[]) Invoke(Object[]) Invoke(Object[]) Invoke(Object[])

调用由具有指定参数的实例反映的构造函数,为不常用的参数提供默认值。Invokes the constructor reflected by the instance that has the specified parameters, providing default values for the parameters not commonly used.

(Inherited from ConstructorInfo)
IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean) IsDefined(Type, Boolean)

检查是否定义了指定的自定义特性类型。Checks if the specified custom attribute type is defined.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[]) SetCustomAttribute(ConstructorInfo, Byte[])

使用指定的自定义属性 Blob 设置自定义属性。Set a custom attribute using a specified custom attribute blob.

SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder) SetCustomAttribute(CustomAttributeBuilder)

使用自定义属性生成器设置自定义属性。Set a custom attribute using a custom attribute builder.

SetImplementationFlags(MethodImplAttributes) SetImplementationFlags(MethodImplAttributes) SetImplementationFlags(MethodImplAttributes) SetImplementationFlags(MethodImplAttributes)

设置此构造函数的方法实现标志。Sets the method implementation flags for this constructor.

SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>) SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>) SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>) SetMethodBody(Byte[], Int32, Byte[], IEnumerable<ExceptionHandler>, IEnumerable<Int32>)

使用指定的 Microsoft 中间语言 (MSIL) 指令的字节数组创建构造函数体。Creates the body of the constructor by using a specified byte array of Microsoft intermediate language (MSIL) instructions.

SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[]) SetSymCustomAttribute(String, Byte[])

设置与符号信息关联的此构造函数的自定义特性。Sets this constructor's custom attribute associated with symbolic information.

ToString() ToString() ToString() ToString()

ConstructorBuilder 形式返回此 String 实例。Returns this ConstructorBuilder instance as a String.

显式界面实现

ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) ICustomAttributeProvider.GetCustomAttributes(Boolean) Inherited from MemberInfo
ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) Inherited from MemberInfo
ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) ICustomAttributeProvider.IsDefined(Type, Boolean) Inherited from MemberInfo
_ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _ConstructorBuilder.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

_ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorBuilder.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

_ConstructorBuilder.GetTypeInfoCount(UInt32) _ConstructorBuilder.GetTypeInfoCount(UInt32) _ConstructorBuilder.GetTypeInfoCount(UInt32) _ConstructorBuilder.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

_ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorBuilder.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

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

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from ConstructorInfo)
_ConstructorInfo.GetType() _ConstructorInfo.GetType() _ConstructorInfo.GetType() _ConstructorInfo.GetType()

获取表示 Type 类型的 ConstructorInfo 对象。Gets a Type object representing the ConstructorInfo type.

(Inherited from ConstructorInfo)
_ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _ConstructorInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

(Inherited from ConstructorInfo)
_ConstructorInfo.GetTypeInfoCount(UInt32) _ConstructorInfo.GetTypeInfoCount(UInt32) _ConstructorInfo.GetTypeInfoCount(UInt32) _ConstructorInfo.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from ConstructorInfo)
_ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _ConstructorInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from ConstructorInfo)
_ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_2(Object, BindingFlags, Binder, Object[], CultureInfo)

为 COM 对象提供对 Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) 方法的版本无关的访问。Provides COM objects with version-independent access to the Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) method.

(Inherited from ConstructorInfo)
_ConstructorInfo.Invoke_3(Object, Object[]) _ConstructorInfo.Invoke_3(Object, Object[]) _ConstructorInfo.Invoke_3(Object, Object[]) _ConstructorInfo.Invoke_3(Object, Object[])

为 COM 对象提供对 Invoke(Object, Object[]) 方法的版本无关的访问。Provides COM objects with version-independent access to the Invoke(Object, Object[]) method.

(Inherited from ConstructorInfo)
_ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo) _ConstructorInfo.Invoke_4(BindingFlags, Binder, Object[], CultureInfo)

为 COM 对象提供对 Invoke(BindingFlags, Binder, Object[], CultureInfo) 方法的版本无关的访问。Provides COM objects with version-independent access to the Invoke(BindingFlags, Binder, Object[], CultureInfo) method.

(Inherited from ConstructorInfo)
_ConstructorInfo.Invoke_5(Object[]) _ConstructorInfo.Invoke_5(Object[]) _ConstructorInfo.Invoke_5(Object[]) _ConstructorInfo.Invoke_5(Object[])

为 COM 对象提供对 Invoke(Object[]) 方法的版本无关的访问。Provides COM objects with version-independent access to the Invoke(Object[]) method.

(Inherited from ConstructorInfo)
_MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MemberInfo.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from MemberInfo)
_MemberInfo.GetType() _MemberInfo.GetType() _MemberInfo.GetType() _MemberInfo.GetType()

获取一个表示 MemberInfo 类的 Type 对象。Gets a Type object representing the MemberInfo class.

(Inherited from MemberInfo)
_MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr) _MemberInfo.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

(Inherited from MemberInfo)
_MemberInfo.GetTypeInfoCount(UInt32) _MemberInfo.GetTypeInfoCount(UInt32) _MemberInfo.GetTypeInfoCount(UInt32) _MemberInfo.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from MemberInfo)
_MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MemberInfo.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from MemberInfo)
_MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _MethodBase.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from MethodBase)
_MethodBase.GetType() _MethodBase.GetType() _MethodBase.GetType() _MethodBase.GetType()

有关此成员的说明,请参见 GetType()For a description of this member, see GetType().

(Inherited from MethodBase)
_MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr) _MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr) _MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr) _MethodBase.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can then be used to get the type information for an interface.

(Inherited from MethodBase)
_MethodBase.GetTypeInfoCount(UInt32) _MethodBase.GetTypeInfoCount(UInt32) _MethodBase.GetTypeInfoCount(UInt32) _MethodBase.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from MethodBase)
_MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _MethodBase.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from MethodBase)

Extension Methods

GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type) GetCustomAttribute(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified member.

GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean) GetCustomAttribute(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义特性,并可选择检查该成员的上级。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo) GetCustomAttribute<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义特性。Retrieves a custom attribute of a specified type that is applied to a specified member.

GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean) GetCustomAttribute<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义特性,并可选择检查该成员的上级。Retrieves a custom attribute of a specified type that is applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo) GetCustomAttributes(MemberInfo)

检索应用于指定成员的自定义特性集合。Retrieves a collection of custom attributes that are applied to a specified member.

GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean) GetCustomAttributes(MemberInfo, Boolean)

检索应用于指定成员的自定义特性集合,并可选择检查该成员的上级。Retrieves a collection of custom attributes that are applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type) GetCustomAttributes(MemberInfo, Type)

检索应用于指定成员的指定类型的自定义特性集合。Retrieves a collection of custom attributes of a specified type that are applied to a specified member.

GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean) GetCustomAttributes(MemberInfo, Type, Boolean)

检索应用于指定成员的指定类型的自定义特性集合,并可选择检查该成员的上级。Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member.

GetCustomAttributes<T>(MemberInfo) GetCustomAttributes<T>(MemberInfo) GetCustomAttributes<T>(MemberInfo) GetCustomAttributes<T>(MemberInfo)

检索应用于指定成员的指定类型的自定义特性集合。Retrieves a collection of custom attributes of a specified type that are applied to a specified member.

GetCustomAttributes<T>(MemberInfo, Boolean) GetCustomAttributes<T>(MemberInfo, Boolean) GetCustomAttributes<T>(MemberInfo, Boolean) GetCustomAttributes<T>(MemberInfo, Boolean)

检索应用于指定成员的指定类型的自定义特性集合,并可选择检查该成员的上级。Retrieves a collection of custom attributes of a specified type that are applied to a specified member, and optionally inspects the ancestors of that member.

IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type) IsDefined(MemberInfo, Type)

确定是否将指定类型的任何自定义属性应用于指定的成员。Indicates whether custom attributes of a specified type are applied to a specified member.

IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean) IsDefined(MemberInfo, Type, Boolean)

指示一个指定类型的自定义特性是否应用于一个指定的数字,并选择性地应用于其的上级。Indicates whether custom attributes of a specified type are applied to a specified member, and, optionally, applied to its ancestors.

GetMetadataToken(MemberInfo) GetMetadataToken(MemberInfo) GetMetadataToken(MemberInfo) GetMetadataToken(MemberInfo)
HasMetadataToken(MemberInfo) HasMetadataToken(MemberInfo) HasMetadataToken(MemberInfo) HasMetadataToken(MemberInfo)

适用于