问题描述
如果我有这个属性
Dim m_name为字符串
属性名称()为字符串
获取
返回m_name
end获取
设置(byval Value as string)
m_name = Value
结束集
结束财产
在我的代码中我必须使用m_name或名称?
If i have this property
Dim m_name as string
Property name() as string
Get
return m_name
end Get
Set (byval Value as string)
m_name = Value
End set
End property
In my code i have to use m_name or name ?
推荐答案
个人偏好。我更喜欢使用私有变量上的属性,
,因为这会增加验证的好处,特别是在为物业分配
a新值时。
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http://classicvb.org/petition/>
Personal preference. I prefer using the property over the private variable,
because this would add the benefit of validation, especially when assigning
a new value to the property.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
这篇关于设定......我用什么。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!