About get value from app.config file.

  • Thread starter Thread starter Jet Leung
  • Start date Start date
J

Jet Leung

Hi all,
I had written a codes like this:
// my code 1
string a;
System.Configuration.AppSettingsReader AppReader=new AppSettingsReader();
a=AppReader.GetValue("my_key",typeof(string)).toString();

// my code 2
string b;
b=System.Configuration.ConfigurationSettings.AppSettings["my_key"].toString(
);

And I can get the same result from a and b. Actually I want to know what is
the different between AppSettingsReader and
ConfigurationSettings.AppSettings["key"] to get the value from the
app.config?

Thank you.
 
There is no difference.

The AppSettings property on the ConfigurationSettings class is just a static
property giving you access to the AppSettingsReader object for your
application.

HTH

Ollie
 
Back
Top