Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global Variables C#
Message
From
13/12/2009 04:51:17
 
 
To
12/12/2009 19:23:05
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01438724
Message ID:
01438816
Views:
59
Hi,

The more subtle decision is probably whether to put these in a static or non-static class? In general I go for static because with something like this:
static class AppSettings
        {
            public static string ConnString;

            static AppSettings()
            {
                ConnString = new SomeLongRunningProcess().GetConnString();
            }
        }
the long running bit is guaranteed not to be called unless the ConnString value is actually required elsewhere in code. If it were a non-static class the static constructor would fire un-neccessarily the first time an instance of the class was created....
Best,
Viv


>Sorry to be late to the conversation, but I just wanted to mention that the key to making all this work is the fact that you need to use static properties and/or methods.
>
>~~Bonnie
>
>
>
>>Viv
>>
>>I think I have this working now, thanks to your patience and Cetin's.
>>
>>I used a variation on what both of you suggested, as it fit into what I've already done in the app.
>>
>>While at it, this newbie discovered how to use App.config, and it's pretty slick. I'll have dozen of uses for it.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform