Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Shared constants
Message
From
15/08/2005 10:53:30
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
15/08/2005 06:36:37
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01040828
Message ID:
01040999
Views:
17
Thanks; a class field seems like the ideal solution for my current needs.

>Hilmar,
>Besides ConfigurationSettings there is of course const class member. You could have your constants in a namespace like:
>
>
>namespace myApplication
>{
> class definitions
> {
>  public const string myConStr = "...";
> }
>}
>
>
>and refer to it as:
>myApplication.definitions.myConStr
>from anywhere. However like VFP if you change the value of myConStr, any other classes depending on the value should be recompiled. An alternative is readonly fields.
>
>
>namespace myApplication
>{
> class definitions
> {
>  public static readonly string myConStr = "...";
> }
>}
>
>you again refer to it as:
>myApplication.definitions.myConStr
>
>However if value is changed it's only 'definitions' class that you need a recompile (other classes obtain value at runtime despite compile time if it's a field and not a constant). Also with constants and fields you're not limited to simple types and could get the value using a method (and say read from a txt,xml file or ask to user etc). ie:
>
>
>namespace myApplication
>{
> class definitions
> {
>  public static readonly DataLocation myDataLoc = new DataLocation();
> }
> class DataLocation
> {
>   // fields
>   public DataLocation() {...}
> }
>}
>
>Cetin
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform