文章内容
2017/3/8 13:56:20,作 者: 黄兵
C#中DefaultValueAttribute的使用
首先说明:
DefaultValueAttribute是指定属性 (Property) 的默认值。
命名空间:System.ComponentModel
程序集:System(在 system.dll 中)
比如我们这样写:
那么要想得到这个555并不是用
而应该这样写:
这个时候_Value的值为555,如果用上面的方法得到的_UserName的值依然为NULL。具体我也说不明白,但是在一个属性上面加上这个Attribute,很会让人误解。
参见:http://msdn.microsoft.com/zh-cn/library/system.componentmodel.defaultvalueattribute(VS.80).aspx
转载自:csdn-JRoger_
评论列表