What is the difference between these two snippets?
Public Property UserName As String
and
Public Property User As String
Get
Return _User
End Get
Set(ByVal value As String)
_User = value
End Set
End Property
I am sorry if this is a duplicate or stupid question. I am not used to VB.NET, I’m more used to C#. I am trying to translate this into C# and I have no room for mistakes.
There’s no difference. The first is just the short version of the second.
But if you want to restrict the setter or do something more in the properties than to get/set the variable, you need to use the second version.
So it’s the same as (in C#)
Auto-Implemented Properties (Visual Basic)
Auto-Implemented Properties (C# Programming Guide)