Jun 1, 2017

Correct way to use ConfigurationManager.AppSettings Property in c#

In this blog post I will take you through my simple code where I had to get my "SiteUrl" value present in app.config file.

We will be using ConfigurationManager.AppSettings property to get our value.

Make sure your app.config file in your Console application is having below value
        



Now in our program.cs lets get this value in the below manner

string siteUrl = ConfigurationManager.AppSettings["SiteUrl"];

Make sure you have proper references. We need to add a reference to using System.Configuration;

Hope it helps!
Thanks fellas.

No comments: