如何使用 codedom 在方法签名中使用 'new' 关键字创建方法
How to Create a Method with 'new' keyword in its method signature using codedom
我想使用 codedom 在其方法签名中动态生成一个带有 'new' 关键字的方法。想要生成这样的东西
private new void MyMethod()
{
}
类似于:
CodeMemberMethod myMethodMethod = new CodeMemberMethod();
myMethodMethod.Attributes = MemberAttributes.Private | MemberAttributes.New;
myMethodMethod.Name = "MyMethod";
这是一个MemberAttributes
:MemberAttributes.New
。
当您调用 TypeBuilder.DefineMethod
, just include MethodAttributes.NewSlot
时:
Indicates that the method always gets a new slot in the vtable.
我想使用 codedom 在其方法签名中动态生成一个带有 'new' 关键字的方法。想要生成这样的东西
private new void MyMethod()
{
}
类似于:
CodeMemberMethod myMethodMethod = new CodeMemberMethod();
myMethodMethod.Attributes = MemberAttributes.Private | MemberAttributes.New;
myMethodMethod.Name = "MyMethod";
这是一个MemberAttributes
:MemberAttributes.New
。
当您调用 TypeBuilder.DefineMethod
, just include MethodAttributes.NewSlot
时:
Indicates that the method always gets a new slot in the vtable.