using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;namespace MyConfig
{
class Staticvariable:ConfigurationSection
{
[ConfigurationProperty("id")]
public int ID
{
get
{
return (int)this["id"];
}
set
{
this["id"] = value;
}
}
[ConfigurationProperty("Value")]
public int ID
{
get
{
return (int)this["Value"];
}
set
{
this["Value"] = value;
}
}
}}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;namespace MyConfig
{
class Staticvariable:ConfigurationSection
{
[ConfigurationProperty("id")]
public int ID
{
get
{
return (int)this["id"];
}
set
{
this["id"] = value;
}
}
[ConfigurationProperty("Value")]
public int ID
{
get
{
return (int)this["Value"];
}
set
{
this["Value"] = value;
}
}
}}
命名空间、继承、attribute和property。找一本书好好看看
http://msdn.microsoft.com/zh-cn/library/a3hd7ste(v=VS.80).aspx
就这个不明白帮解释一下不行吗?为什么老攻击我?我有不会的不能问问吗? 那本基础讲[ConfigurationProperty("id")]这种表达式是什么意思了?感谢给我帮助的人
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;namespace MyConfig
{
class Staticvariable:ConfigurationSection//自定义的配置节点
{
[ConfigurationProperty("id")]//有一个名字叫做id的配置特性,改特性的值会映射到这个类的ID这个Property上 ( id=123 ,那么这个类的实例的ID就会是123) 下同,但是这个类有点奇怪,为什么把id和value两个配置特性都映射到了ID上 public int ID
{
get
{
return (int)this["id"];
}
set
{
this["id"] = value;
}
}
[ConfigurationProperty("Value")]
public int ID
{
get
{
return (int)this["Value"];
}
set
{
this["Value"] = value;
}
}
}}