【发布时间】:2012-01-24 16:01:10
【问题描述】:
在我的项目上运行代码分析时,我收到以下消息:
CA1051 : Microsoft.Design : Because field 'ClassName.VarName' is visible outside of its declaring type, change its accessibility to private and add a property, with the same accessibility as the field has currently, to provide access to it.
要解决这个问题,我可以更改以下行:
Public VarName As String
到这里:
Public Property VarName As String
我不明白为什么Property 关键字在这种特殊情况下如此重要。谁能解释为什么将此成员更改为Property 会对代码分析产生重大影响?我做错了吗?
【问题讨论】:
标签: .net vb.net visual-studio-2010 code-analysis