Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why I can not make my Connection String a const?
Message
From
23/09/2008 13:45:42
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01349894
Message ID:
01349944
Views:
24
This message has been marked as a message which has helped to the initial question of the thread.
>>>Thanks again.
>>
>>
>>Make it static then
>>
>>static private string xxx = "yyyy";
>>
>
>Thanks, that seems to compile. BTW, I don't understand a problem with VS 2005 SP1. It says build succeeded and then shows 100+ errors which are not really errors. Somehow it often can not resolve references properly and even often shows keywords highlighted as errors.


If you want to make it readonly

Readonly fields can be initialized (1) in the declaration and (2) in the constructor
A readonly field can be considered as a runtime constant
static class ClassName
{
     static readonly string xxx = "yyy";
     static readonly string zzz = AnotherClass.Method();


}
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform