HOW-TO Initialize expanded properties?

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
2 posts Page 1 of 1
Contributors
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

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!
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

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
2 posts Page 1 of 1
Return to “Tutorial Requests”