【发布时间】:2018-01-30 18:32:39
【问题描述】:
我工作的公司最近有一个程序员离职,他用 VB 做了一个 WPF 项目,但现在已经不能工作了。我被指派修复这个项目。我注意到的第一件事是他拥有的这些属性变量的构建错误。他们看起来像这样
Public Property BasePath As String = "this is a string to db properties"
Public Property header As New CurrentRun_HDR
Public Property PageHolder As New List(Of Page)
Public Property ScheduleHolder As New List(Of Page)
Public Property HeaderHolder As New List(Of Page)
Private Property LastUpdate As DateTime = Now
Private Property RefreshDate As DateTime = Now
Public Property MouseEnabled As Boolean = True
Visual Studio 2008 说属性需要获取、设置,所以我通过执行这样的操作来满足第一个。
Private _Prop2 As String = "this is a string to db properties"
Property BasePath() As String
Get
Return _Prop2
End Get
Set(ByVal value As String)
_Prop2 = value
End Set
End Property
我不确定如何修复其他错误,例如下一个
Public Property header As New CurrentRun_HDR 表示 new 在这种情况下无效。当我用谷歌搜索它时,它说你可以像这段代码一样自动实现属性,但它们会在构建时抛出错误,任何帮助将不胜感激。我在 Visual Studio 2008 中使用 .Net Framework 3.5
我去过这个site
【问题讨论】:
-
我认为自动实现属性是在 VS 2010 中引入的,那么它是如何编译的?
-
@Plutonix 正确 - 在 VS 2010 中添加了自动实现属性。
-
有趣我不确定,但我会尝试在 vs2010 中打开它,看看会发生什么。那家伙刚刚说他们使用 vs 2008,我相信他们的话