Code
public class Global : System.Web.HttpApplication
{
public const string globalServernameSHA = string.Empty;
public static string globalSqlConnection = string.Empty;
protected void Application_Start(object sender, EventArgs e)
{
globalServernameSHA = ConfigurationManager.AppSettings["varServernameSHA"].ToString();
globalSqlConnection = ConfigurationManager.ConnectionStrings["varConnectionString"].ToString();
}
These variables should be read just once and definitely should be read only.
They have to be available for whole project and therefore should be public.
Is there a way how to define const in code like this ?
Thanks
Declare them as readonly and move initialization to constructor: