微软在ConfigurationManager类里面为我们提供了AppSetting和ConnectionStrings 两个常用配置,

但是有时候我们需要自定的配置,例如

<image left="40" top="250" width="300" height="200" uri="test.png"/>

这样的配置要如何实现呢?

步骤入如下:

1、打开App.config

2、在App.config中添加,下面的<configSection>

 <configuration>
<configSections>
<section name="image" type="System.Configuration.SingleTagSectionHandler"/>
</configSections>

3、<configSection>必须是第一个XML节点

4、如果<configSection>以及存在了,就不用加。

5、然后在<configration>下面加入<image>节点

 <configuration>
<configSections> <section name="image" type="System.Configuration.SingleTagSectionHandler"/>
</configSections> <image left="40" top="250" width="300" height="200" uri="test.png"/> </entityFramework>
</configuration>

6、然后程序就可以读了!

代码如下

namespace TestFilter
{
class Program
{
static void Main(string[] args)
{ Hashtable remoteDataSource =
(Hashtable)ConfigurationManager.GetSection("image");
string left= (string)remoteDataSource["left"];
string top= (string)remoteDataSource["top"];
string uri = (string)remoteDataSource["uri"];
}
}
}

最新文章

  1. 第七章 人工智能,7.6 DNN在搜索场景中的应用(作者:仁重)
  2. HDU 5934 Bomb(炸弹)
  3. java守护线程的理解
  4. json_encode详解,转义
  5. J2EE中你必须了解的13种技术规范
  6. 如何使用eclipse进行嵌入式Linux的开发
  7. java18 任务调度
  8. iOS 9 地图定位崩溃 n: &#39;Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal-&gt;fClient)&#39;
  9. js动画学习(二)
  10. HDU4325--Flowers--树状数组,离散化
  11. Appium 解决手势密码 java
  12. webx request注入单例增强实现
  13. 使用 WeihanLi.Npoi 操作 CSV
  14. LeetCode算法题-Number Complement(Java实现-五种解法)
  15. 深入理解Fabric环境搭建的详细过程
  16. JumpServer 安装配置
  17. 我的第二本译作《精通OpenStack》上架啦:前言、目录和样章
  18. 别人的Linux私房菜(19)认识与分析日志文件
  19. Educational Codeforces Round 58 (Rated for Div. 2) F dp + 优化(新坑) + 离线处理
  20. WebService学习总结(一)——WebService的相关概念

热门文章

  1. Nginx配置文件的反向代理
  2. WXS-运算符
  3. php str_getcsv解决explode不能解决的问题
  4. 生命不息,奔跑不止,持之以恒,勇攀高峰——JasonCeng的跑步打卡
  5. LeetCode 665. 非递减数列(Non-decreasing Array)
  6. LeetCode 50. Pow(x, n) 12
  7. OpenCV基于字节指针进行高效像素遍历
  8. [Visual Studio] - 使用 Fiddler 时,禁止监控 VSHub 请求的方法
  9. .NET Core IOC AOP
  10. Java基础笔试练习(六)