private variable vs. actual property in a class module?

  • Thread starter Thread starter SteveS
  • Start date Start date
S

SteveS

What's the difference in using the private variable as opposed to the actual
property in a class module? Which is better or more efficient? (
LoginObject.Save (_loginName) or LoginObject.Save (me.LoginName)

FOR EXAMPLE:

Class MyClass

Private _loginName As String
Public Property LoginName() As String
Get
Return _loginName
End Get
Set(ByVal Value As String)
_loginName = Value.ToLower()
End Set
End Property

public sub Save()
dim LoginObject as new Data.LoginObject
'****** what is the difference in these 2 lines? *******
LoginObject.Save (_loginName)
LoginObject.Save (me.LoginName)
'******************************************
end function

End Class


Thank You,

SteveS
 
I don't think it makes any difference the JIT will optimize the Me.LoginName
so there won't be any performance difference.

In my opinion using the property (Me.LoginName) is advisable, because in
that case you're using OO encapsulation.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
Back
Top