Click here to Skip to main content
15,881,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
In my new project they have used one code like
C#
string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];

What is the use of this code? why the are using this?
What could be the use of this code?
Posted
Updated 6-May-13 23:55pm
v2
Comments
Aswin K 7-May-13 5:51am    
From my understanding, it means that the developer has provided with a standard password value in app.config file.
In "string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];" they are trying to assign that value to a variable A.
Check your app.config file for "checkpassword"

There will be a web.config/app.config file existing on that application. Check that.

That is xml file usually contains all the configuartion information for the application.

You will find the key CheckPassword inside AppSettings tag under parent tag configuration inside that file something like below.

XML
<configuration>
    <appSettings>
        <add key="CheckPassword" value="MyValue" />
    </appSettings>
</configuration>


We store some sensitive information in this manner as to avoid writing it many times whenever needed inside our application.
And if it needs to be changed, then we just need to change at that configuration file and the application will work as intact.

So, according to this hierarchy, you will access that value like below.
C#
string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];
// So, value of A will be "MyValue"



Explore More

1. appSettings Element (General Settings Schema)[^]
Quote:
Contains custom application settings, such as file paths, XML Web service URLs, or any information that is stored in the.ini file for an application.

2. ASP.NET appSettings[^]
3. ASP.NET Configuration File Hierarchy and Inheritance[^]
4. ASP.NET Configuration Files[^]
 
Share this answer
 
v2
Comments
Thanks7872 7-May-13 6:24am    
↑ed..!
Thanks Rohan...:)
My Part of answer
You ll get the value of CheckPassword from web.config or app.config.
 
Share this answer
 
With this code you can read the variables of your program that is saved in the web.config or app.config.
you can access to it from all forms.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900