Hi everybody,
I was thinking that instead of accessing my connection string through configuration manager in several procedures of our global static class I'll make it a const property. So, based on another existing const I put
private const string TelephoneRegex = @"(1\s*[-\/\.]?)?(\((\d{3})\)|(\d{3}))\s*[-\/\.]?\s*(\d{3})\s*[-\/\.]?\s*(\d{4})\s*(([xX]|[eE][xX][tT]| )\.?\s*(\d+))*";
private const string ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["FCCMSConnectionString"].ConnectionString;
at the very top of the class.
However, I'm getting this error
Error 1 'Util.ConnectionString' is of type 'string.' A const of reference type other than string can only be initialized with null
Do you know if this is a wrong approach? What can I do to use this as a property?
Thanks in advance.
If it's not broken, fix it until it is.
My Blog