Created
November 25, 2013 22:27
-
-
Save csharpforevermore/7650031 to your computer and use it in GitHub Desktop.
parse a web.config appsetting true / false to boolean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool isTest = Boolean.Parse(ConfigurationManager.AppSettings["appSettingValue"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, just googled this out but it will throw: ArgumentNullException: Value cannot be null.
when the setting is missing from config file. This one may be safer:
bool isTest = Boolean.Parse(ConfigurationManager.AppSettings["appSettingValue"] ?? "false");