Friday, April 26, 2019

C# Defining Application/User Settings: appSettings Vs. ApplicationSettings

Basically there are two WAYs to define settings for a C# Application:

Manually update the app.config xml file (and access the properties via ConfigurationManager.AppSettings["key1"]; )


<appSettings>
 <add key="key1" value="value1"/>
 <add key="key2" value="value2"/>
</appSettings>

Or you can Select your Project, then Properties and Settings:

( access the properties in the code with Properties.Settings.Default.TestEnvironment)

<applicationSettings>
    <Projectname.Properties.Settings>
        <setting name="TestEnvironment" serializeAs="String">
            <value>True</value>
        </setting>
    </Projectname.Properties.Settings>
</applicationSettings>
References: