Monday, August 3, 2009

Default Values to Properties

Got this from:
http://www.vb-helper.com/howto_net_default_value.html


The DefaultValue attribute gives a property's default value. If you right-click on the property in the Properties window and select Reset, the property is reset to this value.

Usually the DefaultValue is the same as the property's initial value. This example uses the same constant for the FirstName property's initial and default values.

 
Private Const m_DefaultFirstName As String = "<unknown " & _
"first name>"
Private m_FirstName As String = m_DefaultFirstName

<DefaultValue(m_DefaultFirstName)> _
Public Property FirstName() As String
Get
Return m_FirstName
End Get
Set(ByVal Value As String)
m_FirstName = Value
End Set
End Property

No comments: