473,569 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 CodeSnippetExpr ession 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

Sep 6 '06 #1
2 2232
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]
- mv*@spam.guard. caspershouse.co m

"Venkat" <sv********@gma il.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
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 CodeSnippetExpr ession 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

Sep 6 '06 #2
Hi Nicholas,
Thanks for your response. Yes, I already checked that and
CodeMemberMetho d cannot contain a CodeMemberFiled ; only "Statement" is
allowed :-(

-Venkat

Nicholas Paldino [.NET/C# MVP] wrote:
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]
- mv*@spam.guard. caspershouse.co m

"Venkat" <sv********@gma il.comwrote in message
news:11******** *************@h 48g2000cwc.goog legroups.com...
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 CodeSnippetExpr ession 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
Sep 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
30548
by: The8thSense | last post by:
how to declare static varible and static method inside a class ? i try "public static ABC as integer = 10" and it said my declaration is invalid Thanks
14
2332
by: J.S. | last post by:
In a Windows Form application, which is the better method to concatenate large blocks of code? 1. Reading the text from text files. 2. Adding the text to the VB file itself? Thanks! J.S. --
9
3973
by: lee.chappers | last post by:
How can I make the CodeDom generate the following C# method? protected sealed override void Test() { } I've tried using: domMethod.Attributes = MemberAttributes.Override | MemberAttributes.Family | MemberAttributes.Final;
0
299
by: Venkat | last post by:
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
17
1807
by: Steven T. Hatton | last post by:
I didn't think this was possible in C++. I don't believe Stroustrup mentions this anywhere in TC++PL(SE). I've never seen it used in code that I can recall. Is this feature widely supported? Is it used? #include <iostream> struct Bar { void f() { struct Local{Local(){std::cout <<"I am local"<<std::endl; }}; Local l; }
3
20843
by: johnmmcparland | last post by:
Hi all, I would like to have a static constant array inside a class definition which would contain the number of days in each month (I am writing a Date class as an exercise). However my attempts so far have been unsuccessful. Take this Test class as an example // test.hpp
12
4781
by: PGP | last post by:
I notice that local classes are not supported in C#. Could you please discuss why this is so? Was this a bad coding practice to begin with?
5
2176
by: dancer | last post by:
Using ASP.net 1.1 and VB Is it possible to declare variables in their own subroutine? I had my DIM statements within a sub that worked just fine. I wanted to be able to use them in another sub, so I isolated them in their own subroutine. But when I call that subroutine within another sub and then try to use those variables, it does not...
28
2531
by: cpluslearn | last post by:
Hi, I have a local class inside a function template. I am able to wrap any type in my local class. Is it legal C++? What type of class is Local? Is it a class template or regular class? Thanks in advance. --dhina...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.