Roy Osherove

View Original

AppSettings Coolness

Say you want to store a setting in an XML config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="WebServiceUrl" value="http://mypublicserver/smartclientservice.asmx?wsdl" />
</appSettings>
</configuration>

To access the setting from within your app use the ConfigurationSettings class:

_service.Url = ConfigurationSettings.AppSettings["WebServiceUrl"].ToString();
[via StronglyTyped]

heh! That is pure coolness (as geeky as i might seem..)