Using AppSetting to set const variables

Viewed 5459

How can I do this:

private const string myConstant = ConfigurationManager.AppSettings["key"];

I've got this error message: The expression being assigned to 'XXX' must be constant.

I know that this AppSettings will probably never change but I don't want to hard-coded the value in my controler as below:

private const string myConstant = "XXX";

I was thinking to create a Singleton but I don't know if this is really a good idea.. any suggestions?

Thank you :)

0 Answers
Related