本文介绍了这段代码有什么用? System.Configuration.ConfigurationManager.AppSettings [" CheckPassword"];的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的新项目中,他们使用了一个代码,例如

In my new project they have used one code like

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?

推荐答案

<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.

string A = System.Configuration.ConfigurationManager.AppSettings["CheckPassword"];
// So, value of A will be "MyValue"











1. []






1. appSettings Element (General Settings Schema)[^]

Quote:

包含自定义应用程序设置,例如文件路径,XML Web服务URL或存储在其中的任何信息。应用程序的.ini文件。

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. []

3. []

4. []


2. ASP.NET appSettings[^]
3. ASP.NET Configuration File Hierarchy and Inheritance[^]
4. ASP.NET Configuration Files[^]




这篇关于这段代码有什么用? System.Configuration.ConfigurationManager.AppSettings [&QUOT; CheckPassword&QUOT;];的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 04:20