Results 1 to 2 of 2

Thread: Declaring global variable for domain name

  1. #1
    Join Date
    Jan 2009
    Ixonia, WI

    Declaring global variable for domain name


    I am new to .net and C#. I'm trying to create a variable so I can switch between my dev and production site without changing a bunch of html.
    public static class GlobalVariables {
        public static string domain_name { set domain_name="http://dev.domain.com"; }
    The goal is to have in my html anytime i am creating a hyperlink for it to look like this.
    HTML Code:
    <a href="[domain_name]/product-1">Product 1</a>
    So that the only thing i have to do when I move the files over to www.domain.com is change that static string to www. I also need to know what where to store this variable so i can access it across the site. Any help/ideas on how to do this is greatly appreciated it.


  2. #2
    Join Date
    Jun 2014
    Variables declared outside of a block are called global variables. Global variables have program scope,

    int a; // global variable

    int main()
    int b; // local variable b

    // global vars can be seen everywhere in program
    // so we can change their values here
    a = 5;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center