Non Virtual method using CodeMemberMethod -- CodeDOM

A

Abhi

I am using CodeDOM namespace to dynamically generate code in C#. But when I
am creating method using “CodeMemberMethod†then its creating a virtual
method even though I am not specifying anything to create a virtual method. I
am using following code to add method:

CodeMemberMethod testMethod = new CodeMemberMethod();
testMethod.Name = "testMethod";
testMethod.Attributes = MemberAttributes.Public;
testMethod.Statements.Add(new CodeSnippetStatement("//TODO: Code goes
here....."));
testClassType.Members.Add(testMethod);

Question: How to create method without Virtual keyword?
 
A

Abhi

That's strange MemberAttributes.Public | MemberAttributes.Final works and
Virtual method is not created. Thanks anyway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top