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 ...
随机推荐
- L07-Linux配置ssh免密远程登录
本文配置可实现:集群服务器之间相互可以ssh免密登录.若只想从单一机器(如master)ssh免密登录其他机器(slave1.slave2),则只跟着操作到第二步即可. 建议先花两三分钟把全文看完再跟 ...
- gradle第一篇:初入门
有的时候,感觉技术真是一年一个样,之前呢ant式微,被maven取代,而现在呢,maven慢慢式微,又渐渐要被gradle取代,不说多了我们现在就来讲一讲gradle吧. 第一步——安装: ①安装所需 ...
- Flask中路由系统以及蓝图的使用
一.Flask的路由系统 1.@app.route()装饰器中的参数 methods:当前URL地址,允许访问的请求方式 @app.route("/info", methods=[ ...
- Linux下which命令使用详解(转)
我们经常在linux要查找某个文件,但不知道放在哪里了,可以使用下面的一些命令来搜索: which 查看可执行文件的位置. whereis 查看文件的位置. locate 配合数据库查看文件位置. f ...
- Vagrant 创建虚拟机
Vagrant 创建虚拟机 1. 下载相关软件 虚拟机软件:vmware virtualbox Vagrant 软件:vagrant cd /tmpwget http://download.vir ...
- WCF系列教程之WCF操作协定
一.简介 1.在定义服务协定时,在它的操作方法上都会加上OperationContract特性,此特性属于OperationContractAttribute 类,将OperationContract ...
- Cloudera Manager安装之利用parcels方式(在线或离线)安装3或4节点集群(包含最新稳定版本或指定版本的安装)(添加服务)(Ubuntu14.04)(五)
前期博客 Cloudera Manager安装之Cloudera Manager 5.6.X安装(tar方式.rpm方式和yum方式) (Ubuntu14.04) (三) 如果大家,在启动的时候,比如 ...
- git提交代码到远程仓库
1.仓库初始化 git init 2.连接仓库 git remote add origin 仓库地址 3.查看状态 git status 4.将文件添加到暂存区 git add 状态里的新文件 5.将 ...
- Redis: under the hood---转载
http://pauladamsmith.com/articles/redis-under-the-hood.html#redis-under-the-hood How does the Redis ...
- [转]Creating an OData v3 Endpoint with Web API 2
本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/odata-support-in-aspnet-web-api/odata- ...