Shorthand for Property declaration in VB

Discussion in 'ASP .Net' started by David W, Jan 17, 2007.

  1. David W

    David W Guest

    I have a very simple class that just stores a number of strings so I can use
    them in an ArrayList bound to a Repeater. There is no validation or
    calculations needed for the properties. Is there any shorthand for this
    without having to define a Property and a Get for every single instance
    variable? This gets very old when you have many properties (30+). If I
    just declare the instance vars as public (renaming them without the my) and
    provide no Property accessor, the Repeater can't access them as it
    enumerates. It just seems like an excessive amount of code for something so
    simple.

    Public Class SimpleClass
    Private myName, myLabel As String

    Public Sub New(ByVal Name As String, ByVal Label As String)
    Me.myName = Name
    Me.myLabel = Label
    End Sub

    Public ReadOnly Property Name() As String
    Get
    Return Me.myName
    End Get
    End Property

    Public ReadOnly Property Label() As String
    Get
    Return Me.myLabel
    End Get
    End Property
    End Class
     
    David W, Jan 17, 2007
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. foreach shorthand

    , Mar 25, 2005, in forum: C++
    Replies:
    2
    Views:
    646
    =?iso-8859-1?Q?Ali_=C7ehreli?=
    Mar 25, 2005
  2. Foxpointe

    Shorthand for namespaces

    Foxpointe, Oct 31, 2006, in forum: XML
    Replies:
    4
    Views:
    455
    Foxpointe
    Oct 31, 2006
  3. Replies:
    7
    Views:
    426
  4. Tilman  Kispersky
    Replies:
    2
    Views:
    392
    Paul Hankin
    Jun 8, 2008
  5. asit
    Replies:
    4
    Views:
    3,722
    Roedy Green
    Jul 3, 2008
Loading...

Share This Page