Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Shorthand for Property declaration in VB

Thread Tools

Shorthand for Property declaration in VB

David W
Posts: n/a
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

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
Return Me.myName
End Get
End Property

Public ReadOnly Property Label() As String
Return Me.myLabel
End Get
End Property
End Class

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro like functionality for shorthand variable names Tilman Kispersky Python 2 06-08-2008 02:15 AM
any() and all() shorthand Python 7 01-08-2008 04:26 AM
Shorthand for namespaces Foxpointe XML 4 10-31-2006 09:41 PM
foreach shorthand C++ 2 03-25-2005 10:38 PM
kiwi biz q_'n <== Teeline shorthand for question Quean Computer Support 2 12-23-2004 07:08 AM