0

I was given the following task and I am hoping that someone will be able to guide me in the right direction. Currently, we have code compiling in C#6. Due to varying reasons, some of my fellow coworkers are running C#4 and are unable to upgrade to C#6. I have to slightly alter the code so that it compiles for my coworkers.

In c#6, we have the following code:

using System;
using static SecGlobal.Constants;

with SecGlobal.Constants being:

namespace SecGlobal
{
    public static class Constants
    {
        public const string CONST_DB_SERVER = "server name";
        public const string CONST_MAIN_TIME_ZONE = "Eastern Standard Time";
        ... etc
    }
}

The issue I run into is that the feature "using static" is not available in C#4. Are there any alternatives?

0

1 Answer 1

1

Just replace constant references with a fully qualified name. For instance,

using System;
using static SecGlobal.Constants;

...
string s = CONST_DB_SERVER;
...

Becoming

using System;
...
string s = SecGlobal.Constants.CONST_DB_SERVER;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.