System.Configuration

System.Configuration is a namespace that contains classes for reading and manipulating configuration files. Listing B.48 (configuration.exe.config) shows a sample configuration file.

Listing B.48. Application Configuration File
<configuration>
    <appSettings>
        <add key="Application Name" value="MyApplication" />
        <add key="Application Size" value="10X10" />
        <add key="Application Position" value="Middle" />
        <add key="Application Duration" value="Infinite" />
    </appSettings>
</configuration>

The code in Listing B.49 retrieves the configuration settings (configuration.cs) from the configuration file in Listing B.48.

Listing B.49. Reading an Application Configuration File
 public class ConfigurationMain { static void Main(string ...

Get .NET Common Language Runtime Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.