I'm a C# novice running .NET 3.5, and I'd like to store a bunch of application default values in App.config, as the settings may vary by server environment (e.g. development, staging, production). What I want to do is similar to what's described in this StackOverflow article, but I also want to be able to use non-string values (e.g. int, bool). Something like this (name-values are just examples, btw):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<applicationSettings>
<MyApp>
<setting name="InitText" serializeAs="String">
<value>Hello</value>
</setting>
<setting name="StartAt" serializeAs="Integer">
<value>5</value>
</setting>
<setting name="IsWeekend" serializeAs="Boolean">
<value>True</value>
</setting>
</MyApp>
</applicationSettings>
</configuration>
Could somebody provide an example of how to do this, and how to retrieve the values via C#? I've seen a lot of examples that require using and , but I'm not sure if I need those elements, and if so, how to create them.