Storing Information with Properties

Properties are the public way that callers have to access data stored within fields. With properties, you decide the type of permissions users can have to read and write the actual information. Properties are typically used as fields, but they act as methods. Starting from Visual Basic 2010, properties have been completely revisited; in fact, until Visual Basic 2010, a typical property was implemented as follows:

Private _firstName As StringPublic Property FirstName As String    Get        Return _firstName    End Get    Set(ByVal value As String)        _firstName = value    End SetEnd Poperty

You had a private field in which you stored an incoming value and whose value you returned ...

Get Visual Basic 2015 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.