S
shapper
Hello,
I created a simple class as follows:
Public Class HelloWorld
Public Function SayMessage() As String
Return "Hello World!"
End Function
End Class
Usage:
Dim objHelloWorld As New HelloWorld()
MyLabel.Text = objHelloWorld.SayMessage()
Then I recreated the class using a property:
Public Class HelloWorld
Public ReadOnly Property Message() As String
Get
Return SayMessage()
End Get
End Property
Public Function SayMessage() As String
Return "Hello World!"
End Function
End Class
Usage:
Dim objHelloWorld As New HelloWorld()
MyLabel.Text = objHelloWorld.Message
Which appoach should I use or when to use which one?
Could you advice me on this?
Thanks,
Miguel
I created a simple class as follows:
Public Class HelloWorld
Public Function SayMessage() As String
Return "Hello World!"
End Function
End Class
Usage:
Dim objHelloWorld As New HelloWorld()
MyLabel.Text = objHelloWorld.SayMessage()
Then I recreated the class using a property:
Public Class HelloWorld
Public ReadOnly Property Message() As String
Get
Return SayMessage()
End Get
End Property
Public Function SayMessage() As String
Return "Hello World!"
End Function
End Class
Usage:
Dim objHelloWorld As New HelloWorld()
MyLabel.Text = objHelloWorld.Message
Which appoach should I use or when to use which one?
Could you advice me on this?
Thanks,
Miguel