Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > C# Preprocessor

Reply
Thread Tools

C# Preprocessor

 
 
=?Utf-8?B?SSBhbSBTYW0=?=
Guest
Posts: n/a
 
      03-13-2005
I want declare some const strings in my application but I don't want to
repeat the constents in every page I write in my codebehind I was wondering
if there is some kind of directive or preprocessor I can declare at the top
of my codebehind that will import the constents from a seperate file.

I hope I'm using the correct language I am not sure if it is understandable
but I have to try. Thank you in adavance to anyone that will reply.

Sam-
 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      03-13-2005
Sam:
C# only has a:
#define symbol

which can only be used by other preprocessor commands, unlike C/C++'s
#define symbol value

To achieve what you want, create a class and use a const:


public class Globals{
public const string ApplicationName = "SomeThing";
}

and you can then use the global via:

Globals.ApplicationName

this way you aren't repeating the content every single place..

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)


"I am Sam" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I want declare some const strings in my application but I don't want to
> repeat the constents in every page I write in my codebehind I was

wondering
> if there is some kind of directive or preprocessor I can declare at the

top
> of my codebehind that will import the constents from a seperate file.
>
> I hope I'm using the correct language I am not sure if it is

understandable
> but I have to try. Thank you in adavance to anyone that will reply.
>
> Sam-



 
Reply With Quote
 
 
 
 
=?Utf-8?B?SSBhbSBTYW0=?=
Guest
Posts: n/a
 
      03-13-2005
Hey thanx Karl,

Again you came through. Your the best.

Sam-

"Karl Seguin" wrote:

> Sam:
> C# only has a:
> #define symbol
>
> which can only be used by other preprocessor commands, unlike C/C++'s
> #define symbol value
>
> To achieve what you want, create a class and use a const:
>
>
> public class Globals{
> public const string ApplicationName = "SomeThing";
> }
>
> and you can then use the global via:
>
> Globals.ApplicationName
>
> this way you aren't repeating the content every single place..
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
> http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
>
>
> "I am Sam" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I want declare some const strings in my application but I don't want to
> > repeat the constents in every page I write in my codebehind I was

> wondering
> > if there is some kind of directive or preprocessor I can declare at the

> top
> > of my codebehind that will import the constents from a seperate file.
> >
> > I hope I'm using the correct language I am not sure if it is

> understandable
> > but I have to try. Thank you in adavance to anyone that will reply.
> >
> > Sam-

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preprocessor directives must appear as the first non-whitespace character on a line erin.sebastian@cowaninsurancegroup.com ASP .Net 0 02-14-2006 03:11 PM
Compiler error occurred when try to use a flexible template expression in preprocessor definesCompiler error occurred when try to use a flexible template expression in preprocessor defines snnn C++ 6 03-14-2005 04:09 PM
preprocessor, token concatenation, no valid preprocessor token Cronus C++ 1 07-14-2004 11:10 PM
VHDL Preprocessor The Weiss Family VHDL 2 07-14-2004 05:51 AM
Preprocessor conditional compilation variable not being saved Chris P ASP .Net 0 10-28-2003 08:48 PM



Advertisments