Results 1 to 8 of 8

Thread: readonly variable?!!!

Hybrid View

  1. #1
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    You're absolutely right tygur, on both accounts.
    I misread the question, and ReadOnly variables act like constants.

    There are only a few differences between contants and ReadOnly variables.

    Next to initializing the variable inline (Public ReadOnly curX As Integer = 5), you can also give it a value in the classes constructor.
    VB Code:
    1. Public ReadOnly curX As Integer
    2.  
    3.     Public Sub New()
    4.         curX = 6
    5.     End Sub
    6.     Public Sub New(ByVal NewX As Integer)
    7.         curX = Newx
    8.     End Sub

    ReadOnly variables can be of any type, including reference type variables, where constants can only be Boolean, Byte, Char, Date, Decimal, Double, Integer, Long, Object, Short, Single, String, or the name of an enumeration.
    Last edited by Frans C; Apr 22nd, 2002 at 10:58 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width