Converting Web.config values into enum or List
While developing .NET applications, we always look for configuration values stored in either Web.config
or App.config
. We can simply use the <appSettings
>…</appSettings
> section which is converted to a dictionary or key/value pair object. Can we use a strongly-typed object for the configuration? Yes, we can. With the <configSections
>…</configSections
> node, we can convert configuration values into strongly-typed objects. This is a very useful feature in most cases. However, what if we have requirements like:
- I want to convert a string value into an enum value, regardless of the case sensitivity.