Getting an Array structure from Class Property

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hugh O

    #1

    Getting an Array structure from Class Property

    Hi,
    I am creating a class. I do not have any problem defining the property
    statements except when an array is involved. Would someone be able to show
    me the correct syntax for a Property statement to Get an entire array
    instead of one element of the array.

    thanks,
    hugh



  • alantolan@users.com

    #2
    Re: Getting an Array structure from Class Property


    ....

    Private _items() As String = {"AB", "CD", "EF"}

    Public Property Items() As String()
    Get
    Return _items
    End Get
    Set(ByVal Value As String())
    _items = Value
    End Set
    End Property



    NOTE:
    The Set property does not copy the items, it 'drops' the old array and
    replaces it with the new one.
    In practice I would avoid this.
    A readonly property to return the array and then an Add(xxx) function
    to add items to the array.

    hth
    Alan.

    Comment

    • Hugh O

      #3
      Re: Getting an Array structure from Class Property

      Alan,
      Thanks, I agree. And was only planning a Read Only property.

      hugh

      <alantolan@user s.com> wrote in message
      news:1129319391 .205460.72210@f 14g2000cwb.goog legroups.com...[color=blue]
      >
      > ...
      >
      > Private _items() As String = {"AB", "CD", "EF"}
      >
      > Public Property Items() As String()
      > Get
      > Return _items
      > End Get
      > Set(ByVal Value As String())
      > _items = Value
      > End Set
      > End Property
      >
      >
      >
      > NOTE:
      > The Set property does not copy the items, it 'drops' the old array and
      > replaces it with the new one.
      > In practice I would avoid this.
      > A readonly property to return the array and then an Add(xxx) function
      > to add items to the array.
      >
      > hth
      > Alan.
      >[/color]


      Comment

      Working...