Page 1 of 1

HOW-TO Initialize expanded properties?

Posted: Fri Aug 13, 2010 7:33 pm
by MrAksel
Hey, I'm working on a project and i need to initialize an expanded property like this:
Code: Select all
Public Property Words As String() = {"Bla","Bla"}

Get
Return Words
End Get
Set(ByVal value As String())

End Set

End Property
But here is the error
Code: Select all
Public Property Words As String() = {"Bla","Bla"}  <--- You cannot initialize expanded properties
Help me out of this mess guys, giving rep to the ones who help!

Re: HOW-TO Initialize expanded properties?

Posted: Fri Aug 13, 2010 8:34 pm
by mandai
The idea is to store the current value as a seperate variable outside of the property block:
Code: Select all
    Dim starting As String() = {"Bla", "Bla"}
    Public Property Words() As String()
        Get
            Return starting
        End Get
        Set(ByVal value As String())
            starting = value
        End Set
     End Property