Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static or not and when?

Status
Not open for further replies.

bigfoot

Programmer
May 4, 1999
1,779
0
0
US
Hi All
I'm a long time VB developer learning C#. I'm loving it, but I have a question.

I have a class that reads my config settings out of my web.config file and passes them to several parts of my program.
In the VB world this class was static so I didn't not have ti instantiate it. Can I continue this into the C# world or is there a better way?

Code below.
Code:
  public static class AppConfiguration
  {

    private readonly string m_dbConnectionString;

    public static string DbConnectionString
    {
      get { return m_dbConnectionString; }
    }
  }
 
Well, we just usually use the standard Properties function to read out of the web.config...

String x = <namespace>.Properties.Settings.Default.<settingname>

similar to using my in VB.Net

 
That's what I'm doing in the class. This way if we change any of the property names, they only get changed in one place.

It's why I kept them in a class. There's about 10 or so.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top