home | software | utility classes | application settings utility
Reading a setting from App.config or Web.config is a pretty common task. Here's a class that makes this loads easier: AppSettingsUtil
Assume you need to read an integer from config. If the value is not present, an exception should be thrown:
Perhaps the setting is optional (with a default value of 100). You can code for this too:
Using AppSettingsUtil, either scenario can be bundled into a single:
Other methods exist for reading other types:
Most of these have overloads that support default values for optional config keys:
Please feel free to provide feedback on this class .
Authored by Drew Noakes, February 2005. Use freely, though keep this message in the source intact and report any bugs to me. I also appreciate seeing extensions, or simply hearing that you're using these classes. You may not copyright this work, though may use it in commercial/copyrighted works. Happy coding.