Example
Say, for instance, you want a list of status codes that get checked by your application:
In the App.config, define the section and implement the required values:
<configSections> <section name="StatusCodes" type="System.Configuration.DictionarySectionHandler" /> </configSections>...
<StatusCodes> <clear /> <add key="2" value="Two" /> <add key="3" value="Three" /> <add key="4" value="Four" /> <add key="5" value="Five" /> </StatusCodes>To read these values in code, all you need to do is the following, and you have a Hashtable containing all the values defined in the config file:
Hashtable statusCodes = ConfigurationManager.GetSection("StatusCodes") as Hashtable;
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.