C# Preprocessor

G

Guest

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-
 
K

Karl Seguin

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top