All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
ASP.NET从零起步设计网站全过程(2)_[Asp.Net教程]
2个页面间不通过Session与url的传值方式_[Asp.Net教程]
对初学者的建议:ASP.NET技术的学习顺序_[Asp.Net教程]
2003环境下如何手工修复安装.NET1.1_服务器技术_编程技术
Sql,server,2005的XML最佳实施策略(3)_[SQL,Server教程]
精通数据库系列之入门-技巧篇1_mssql学习_编程技术
轻松掌握Ajax.net系列教程七:使用ModalPopupExtender_[Asp.Net教程]
MS,SQL,常用函数大全_mssql学习_编程技术
ASP.NET技巧:一些常用的数据操作类_[Asp.Net教程]
ASP.NET,2.0角色及成员管理_[Asp.Net教程]
Reading number is top 10 pictures
30 beautiful school beauty4
大四女生借债隆胸成功
奇趣的世界记录3
身材野火台灣美女1
The mother was a stay-at-home children too tired took three baby suicide
Fender Bender that so horrifying1
餐桌上的鱼
到南昌西站了1
湖边的风景
大人物的礼物
Download software ranking
Unix video tutorial6
Be there or be square
尖东毒玫瑰B
Boxer vs Yellow2
matrix3
Ashlynn Video1
Ashlynn Video4
Eclipse 4.2.2 For Win64
Unix video tutorial3
Kung.Fu.Panda.2
delv published in(发表于) 2014/1/10 6:23:12 Edit(编辑)
.NET,2.0,中对配置文件的读写_[Asp.Net教程]

.NET,2.0,中对配置文件的读写_[Asp.Net教程]

.NET 2.0 中对配置文件的读写_[Asp.Net教程]

在基于 .net 2.0 的企业库中,原来的配置应用程序块被废除了,使用了 .net 2.0 自带的读写配置功能,下面我们就来看看 .net 2.0 中读写配置的功能。 即: ConfigurationManager 类
  注意:ConfigurationManager 是处理客户端应用程序配置文件的首选方法;不推荐使用任何其他方法。

  对于 Web 应用程序,建议使用 WebConfigurationManager 类。

  这个类的 AppSettings 属性 在以前1.0 的时候,就有了, 2.0 中增加了 ConnectionStrings 属性。

  这些都不是今天我们要探讨的内容,我们今天要探讨的内容,是把一个配置类保存到配置文件中,以及把这个配置类从配置文件中实例化出来。

  这个配置类,必须是 派生自System.Configuration.ConfigurationSection 类

  如下面的类就是一个配置类


using System.Text;
using System.Configuration;
namespace ConfigTest
{
 class ConfigDataClass : ConfigurationSection
 {
  public ConfigDataClass()
  { }

  [ConfigurationProperty("id")]
  public int ID{
   get{return (int)this["id"];}
   set{ this["id"] = value;}
  }

  [ConfigurationProperty("name")]
  public string Name{
   get{ return this["name"].ToString();}
   set{ this["name"] = value;}
  }

  public override string ToString(){
   StringBuilder info = new StringBuilder();
   info.AppendFormat("id = {0};name = {1}", ID, Name);
   return info.ToString();
  }
 }
}

来源:网络







添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.