How to declare a local const (inside a method) using CodeDOM ?

V

Venkat

Hi,
Can anyone let me know how to declare a local const in a method
using CodeDOM? I am trying to get an output that looks like this:

public void SomeMethod()
{
const int MyInteger = 56;
}

One workaround is to use a CodeSnippetExpression and output the literal
"const" keyword. But that'll make it specific to C#. I prefer to keep
the output language option flexible.

Thanks in advance for your help.


-Venkat
 
N

Nicholas Paldino [.NET/C# MVP]

Venkat,

I'm not sure if this would work, but have you tried attaching a
CodeMemberField for the constant to the function code graph?
 
V

Venkat

Hi Nicholas,
Thanks for your response. Yes, I already checked that and
CodeMemberMethod cannot contain a CodeMemberFiled; only "Statement" is
allowed :-(

-Venkat
Venkat,

I'm not sure if this would work, but have you tried attaching a
CodeMemberField for the constant to the function code graph?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Venkat said:
Hi,
Can anyone let me know how to declare a local const in a method
using CodeDOM? I am trying to get an output that looks like this:

public void SomeMethod()
{
const int MyInteger = 56;
}

One workaround is to use a CodeSnippetExpression and output the literal
"const" keyword. But that'll make it specific to C#. I prefer to keep
the output language option flexible.

Thanks in advance for your help.


-Venkat
 

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