Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Public constant
Message
From
19/03/2013 13:10:36
 
 
To
18/03/2013 15:24:47
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01568710
Message ID:
01568789
Views:
36
Likes (1)
>>>Hi everybody,
>>>
>>>I've defined this constant in the class declaration
>>>
>>>
>>>public const String EncodingXMLString
>>>
>>>
>>>but I can not access it by ClassName.ConstName
>>>
>>>I can change it to be a readonly static property instead, but why I can not use it as a constant? I see a comment by another colleague on another readonly property
>>>
>>>// Huh! Can't use const here - weird.
>>>
>>>Indeed weird - do you see what may be wrong?
>>>
>>>Thanks in advance.
>>
>>Not directly relevant but, IAC, it is much safer to use a static readonly rather than a constant. If you reference a constant defined in one assembly in another then it is cast in stone at compile time. If you subsequently change that value other assemblies would still be using the old value unless recompiled.
>
>Hey - I was about to write that ;)

And probably phrase it better :-}
Previous
Reply
Map
View

Click here to load this message in the networking platform