Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why I can not make my Connection String a const?
Message
De
23/09/2008 13:45:42
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01349894
Message ID:
01349944
Vues:
25
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform