You really have to understand what properties are for to be able to create them properly. The idea of a property is that it behaves just like a field from the outside but like method from the inside. Consider the following type with a public field:
vb.net Code:
Public Class SomeClass
Public SomeField As String
End Class
In code, you would get and set that field like so:
vb.net Code:
Dim obj As New SomeType
obj.SomeField = "some value"
Dim val As String = obj.SomeField
Clear enough? Properties work in exactly the same way from the outside. You get and set the value of a property in exactly the same way.
Now, what if that field was not allowed to be longer than 50 characters. How would you validate it? As it stands you can't. You could do what they do in Java and make the field private and then set it using a public method, but that becomes less intuitive for the person writing the code. This is where properties come in. They behave just like fields from the outside but they behave like methods from the inside, allowing you do extra work like validation and raising events. In its simplest form, the code above would become:
vb.net Code:
Public Class SomeClass
Private someField As String
Public Property SomeProperty() As String
Get
Return Me.someField
End Get
Set(ByVal value As String)
Me.someField = value
End Set
End Property
End Class
and you'd use it like so:
vb.net Code:
Dim obj As New SomeType
obj.SomeProperty = "some value"
Dim val As String = obj.SomeProperty
As you can see, that code is exactly the same as when using the public field. We now have the freedom to go into the Get and set methods of the property and add things like validation and event raising, e.g.
vb.net Code:
Public Property SomeProperty() As String
Get
Return Me.someField
End Get
Set(ByVal value As String)
If value.Length > 50 Then
Throw New InvalidArgumentException("Value must be no more than 50 characters long.")
End If
If Me.someField <> value Then
Me.someField = value
Me.OnSomePropertyChanged(EventArgs.Empty)
End If
End Set
End Property
All that extra functionality has been added but the user still treats the property like a field from the outside.