Item 1:Always Use Properties Instead of Accessible Date Members
这个Item主要鼓励大家使用Properties。
值得注意的地方:
public interface INameValuePair
{
object Value
{
get;
set;
}
}
public interface IConstNameValuePair
{
object Name
{
get;
}
object Value
{
get;
}
}
public class Stuff : IConstNameValuePair,INameValuePair
{
private string _name;
private object _value;
public object Name
{
get
{
return _name;
}
}
object IConstNameValuePair.Value
{
get
{
return _value;
}
}
public object Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
}
{
object Value
{
get;
set;
}
}
public interface IConstNameValuePair
{
object Name
{
get;
}
object Value
{
get;
}
}
public class Stuff : IConstNameValuePair,INameValuePair
{
private string _name;
private object _value;
public object Name
{
get
{
return _name;
}
}
object IConstNameValuePair.Value
{
get
{
return _value;
}
}
public object Value
{
get
{
return _value;
}
set
{
_value = value;
}
}
}
posted on 2005-08-12 22:31 海盗 阅读(...) 评论(...) 编辑 收藏