I have a public static class and I am trying to access appSettings from my app.config file in C# and I get the error described in the title.
public static class employee
{
NameValueCollection appSetting = ConfigurationManager.AppSettings;
}
How do I get this to work?
If the class is declared static, all of the members must be static too.
Are you sure you want your employee class to be static? You almost certainly don’t want that behaviour. You’d probably be better off removing the static constraint from the class and the members.