I'm trying to reference a variable from App.config in my C# file. Here's a sample of my code.
App.config:
<appSettings>
<add key="ErrorEmails" value="[email protected]"/>
</appSettings>
Code:
SettingsIO setIO = new SettingsIO();
public static string To = setIO.ReadSetting("ErrorEmails");
The error reads:
A field initializer cannot reference the non-static field, method, or preperty 'test.setIO'.
Should I be using a GET
function? What am I doing wrong?
Use the
system.configuration
class.