C# Preprocessor

Discussion in 'ASP .Net' started by =?Utf-8?B?SSBhbSBTYW0=?=, Mar 13, 2005.

  1. 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-
     
    =?Utf-8?B?SSBhbSBTYW0=?=, Mar 13, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?SSBhbSBTYW0=?=

    Karl Seguin Guest

    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" <> wrote in message
    news:...
    > 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-
     
    Karl Seguin, Mar 13, 2005
    #2
    1. Advertising

  3. 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" <> wrote in message
    > news:...
    > > 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-

    >
    >
    >
     
    =?Utf-8?B?SSBhbSBTYW0=?=, Mar 13, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris P
    Replies:
    0
    Views:
    448
    Chris P
    Oct 28, 2003
  2. The Weiss Family

    VHDL Preprocessor

    The Weiss Family, Jul 14, 2004, in forum: VHDL
    Replies:
    2
    Views:
    3,267
    The Weiss Family
    Jul 14, 2004
  3. Replies:
    0
    Views:
    2,724
  4. Glen
    Replies:
    65
    Views:
    1,571
  5. Cronus
    Replies:
    1
    Views:
    718
    Paul Mensonides
    Jul 15, 2004
Loading...

Share This Page