0

The company I work for recently had a programmer leave and he did a WPF project in VB that is no longer working. I have been assigned to fix the project. The first thing I notice are the build errors on these property variables he has. They look like this

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 is saying that properties need a get, set so I satisfied the first one by doing something like this.

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

I am not sure how to fix the other errors like the next one

Public Property header As New CurrentRun_HDR it is saying new is not a valid in this context. When I googled this it says you can do auto implemented properties like this code is doing but they are throwing errors on the build any help would be greatly appreciated. I am using .Net Framework 3.5 with Visual Studio 2008

I have been to this site

Naim Jamalludin
  • 195
  • 3
  • 16
josh
  • 378
  • 6
  • 20

1 Answers1

-1

The syntax should be something along these lines:

Public Property PageHolder As List(Of Page) = New List(Of Page)

See this question for more examples.

Mike Hofer
  • 16,477
  • 11
  • 74
  • 110
  • Not useful: this doesn't address the Visual Studio version incompatibility, and it's more verbose than the roughly equivalent syntax that was used above. `Public Property ... As New List(Of ...)` is perfectly cromulent. – Craig Jan 30 '18 at 19:13