Monday, October 16, 2006

What is Property, on earth?

@ Properties can be considered smarter fields in that they can be assigned to or read from (like a field), yet when this happens some code in the class executes, and therefore the author of the class can process the value being assigned or returned.

@ Inside the Property block, you write a Get…End Get block, which defines which value the property returns, and a Set…End Set block, which defines how values are assigned to the property.

@ In most cases, a property simply maps to a Private field, so the code for these two blocks often looks like this:

Dim m_BirthDate As Date
Public Property BirthDate() As Date
Get
Return m_BirthDate
End Get
Set(ByVal value As Date)
m_BirthDate = value
End Set
End Property