简体   繁体   中英

How to Create a Method with 'new' keyword in its method signature using codedom

I want to dynamically generate a method with 'new' keyword in its method signature using codedom. Want to generate something like this

private new void MyMethod()
{ 

}

Something like:

CodeMemberMethod myMethodMethod = new CodeMemberMethod();
myMethodMethod.Attributes = MemberAttributes.Private | MemberAttributes.New;
myMethodMethod.Name = "MyMethod";

It is a MemberAttributes : MemberAttributes.New .

When you call TypeBuilder.DefineMethod , just include MethodAttributes.NewSlot :

Indicates that the method always gets a new slot in the vtable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM