Quantcast
Channel: Reading settings from app.config or web.config in .NET - Stack Overflow
Viewing all articles
Browse latest Browse all 29

Answer by pomber for Reading settings from app.config or web.config in .NET

$
0
0

Also, you can use Formo:

Configuration:

<appSettings><add key="RetryAttempts" value="5" /><add key="ApplicationBuildDate" value="11/4/1999 6:23 AM" /></appSettings>

Code:

dynamic config = new Configuration();var retryAttempts1 = config.RetryAttempts;                 // Returns 5 as a stringvar retryAttempts2 = config.RetryAttempts(10);             // Returns 5 if found in config, else 10var retryAttempts3 = config.RetryAttempts(userInput, 10);  // Returns 5 if it exists in config, else userInput if not null, else 10var appBuildDate = config.ApplicationBuildDate<DateTime>();

Viewing all articles
Browse latest Browse all 29

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>