O'Reilly logo

C# for Java Developers by Adam Freeman, Allen Jones

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Application Settings

Configuration files also allow the programmer to define settings that can be read from within an application. The System.Configuration namespace contains the classes that provide access to these settings.

Simple Settings

The <appSettings> section of a configuration file can be used to define key/value pairs, as shown in the following example:

<configuration>
    <appSettings>
        <add key="MyFirstKey" value="MyFirstValue"/>
        <add key="MySecondKey" value="MySecondValue"/>
        <add key="MyThirdKey" value="MyThirdValue"/>
    </appSettings>
</configuration>

These key/value pairs are accessible independently or as a collection through the AppSettings property of the System.Configuration.ConfigurationSettings class, as shown in the following example: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required