Brandon
Brandon

Reputation: 89

What does ConfigurationManager.AppSettings do?

My current understanding is that it making a call to something in my config file and returning data. I am not clear what the parameters are for ConfigurationManager.AppSettings are.

I have looked through this documentation (https://msdn.microsoft.com/en-us/library/1xtk877y%28v=vs.110%29.aspx) but don't quite understand it.

For context this is the code I'm working with:

    string code1 = ConfigurationManager.AppSettings[string1 + string2];
    string code2 = ConfigurationManager.AppSettings[string3];
    string query = new BuildMDXQuery(cube).BuildFetchInventoryQuery(code1, code2);

I'd like to know how I can find what's getting called in my config file, if anything, and what the purpose of using ConfigurationManager.AppSettings is. Thanks!

Upvotes: 2

Views: 1062

Answers (1)

Colin
Colin

Reputation: 4135

It reads from the appSettings section of the config file, so...

Configuration.AppSettings["Whatever"]

...would return "Blah" in the case of:

<configuration>
    <appSettings>
        <add key="Whatever" value="Blah" />
    </appSettings>
</configuration>

Upvotes: 5

Related Questions