C# 读取config
控制台应用程序

App.config:

AppSettings.config:

Program.cs:
string a = ConfigurationManager.AppSettings["a"];
string b = ConfigurationManager.AppSettings["b"];
Console.WriteLine("a={0}", a);
Console.WriteLine("b={0}", b);
Console.ReadKey();
报错:

解决方法:

重新运行结果:

web应用程序
Web.config:

AppSettings.config:

index.aspx.cs代码:
string a = ConfigurationManager.AppSettings["a"];
string b = ConfigurationManager.AppSettings["b"];
divTxt.InnerHtml += "a=" + a+ "<br/>b=" + b;
结果:

C# 读取config的更多相关文章
- 读取config配置
在搭建自动化测试框架时,经常会使用config.properties文件存储配置,文件内容格式如下: 读取config.properties文件代码如下: public class Putils { ...
- 读取Config文件工具类 PropertiesConfig.java
package com.util; import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io ...
- C#改变LInqToSQL的引用地址,读取config的数据库字符串
C#改变LInqToSQL的引用地址,读取config的数据库字符串修改Properties 下 Settings.Settings 下 Settings.Designer.cs 下 return ( ...
- c#读取.config文件内容
今天在做项目的时候,由于程序同时启动多种情况的数据,测试分为多个人,就需要把数据分离开来,于是用了一个临时的配置文件,让测试在配置文件修改相应数据从而让各个测试互相不影响! 步骤: 第一步:添加一个A ...
- ResourceBundle类的方式来读取config.properties配置文件参数值
//获取config.properties配置文件参数值 public static ResourceBundle resource = ResourceBundle.getBundle(" ...
- filter从web.xml读取config的时候中文编码问题
首先,web.xml中不建议出现超出ASCII范围的字符 但是作为一点积累,简单举个例子如下,其核心代码就是new String(String.getBytes(charset_1), charset ...
- Eclipse 读取config目录下文件
最近在一个项目,在项目下新建了一个config配置文件夹,添加一个配置文件config.properties. 使用classpath:config.properties方式加载配置文件, 具体实现代 ...
- 轮子:读取config.ini文件
python: 把config.ini文件成map返回 def get_conf(conf_file): conf = {} ll=list(map(lambda x: x.replace('&quo ...
- python向config、ini文件读取写入
config读取操作 cf = configparser.ConfigParser() # 实例化对象 cf.read(filename) # 读取文件 cf.sections() # 读取secti ...
随机推荐
- 认识CSS中标题引入icon图标
前端之HTML,CSS(十一) icon图标 icon图标的使用 获取网站的中标题icon图标,以京东为例:在域名后添加/favicon.ico Enter打开 鼠标右键,图标另存为下载icon图标, ...
- Mac下运行git报错"xcrun: error: invalid active developer path .."
错误:xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun ...
- mono for android 百度map binding项目(转)
好丫小子之前发布过百度地图android SDK的mono for android绑定dll,许多朋友看过之后说想理解是怎么绑定的,现我把绑定的代码发出来. 针对2.1.2版本百度地图android ...
- FindLine把多行查找改为多行替换
Sub FindLine() Dim textSelection As TextSelection textSelection = DTE.ActiveDocument.Selection textS ...
- FAQ of db2fmp messages in the db2diag.log
http://www-01.ibm.com/support/docview.wss?uid=swg21470035 Technote (FAQ) Question What do these mess ...
- ie和火狐事件addEventListener()及attachEvent()区别分析
Mozilla中: addEventListener的使用方式: target.addEventListener(type, listener, useCapture); target: 文档节点.d ...
- AMQP技术术语
什么是AMQP AMQP,即Advanced Message Queuing Protocol,一个提供统一消息服务的应用层标准高级消息队列协议,是应用层协议的一个开放标准,为面向消息的中间件设计.基 ...
- ThreadPoolExecutor 杂记
When a new task is submitted in method execute(Runnable), and fewer than corePoolSize threads are ru ...
- free 和 delete 把指针怎么了
使用free或delete之后,只是把指针所指的内容给释放掉,但是指针并没有被干掉,还是指向原来位置(并不是执行NULL),此时指针指向的内容为垃圾,被称为“野指针”. 举例说明几个重要容易迷糊的特征 ...
- Eclipse常用快捷键之代码编辑篇
Eclipse是Java开发常用的IDE工具,熟练使用快捷键可以提高开发效率,使得编码工作事半功倍,下面介绍几种常用的代码编辑和补全工具 重命名快捷键:Alt+Shift+R 可用于类名,方法名,属性 ...