Public variable not the same as using a property?
- From: dgk <dgk@xxxxxxxxxxxxx>
- Date: Fri, 14 Sep 2007 09:19:42 -0400
If I have a class with a public variable, isn't this the same as a
private variable with a property? ie, isn't this:
Public Class MyTest
Public MyVar as String
End Class
the same as this:
Public Class MyTest
Private _MyVar as String
Property MyVar
Get
Return _MyVar
End Get
Set (byval value as String)
_MyVar = value
End Set
End Property
End Class
I always thought so, in fact, I thought that the complier converted
the first into the second.
Yet, when I try to databind a generic list of MyTest to a gridview
using the first syntax, it fails. When I use the second syntax it
succeeds.
Does anyone know why?
.
- Follow-Ups:
- Re: Public variable not the same as using a property?
- From: Herfried K. Wagner [MVP]
- Re: Public variable not the same as using a property?
- From: Hal Rosser
- Re: Public variable not the same as using a property?
- From: PvdG42
- Re: Public variable not the same as using a property?
- From: Armin Zingler
- Re: Public variable not the same as using a property?
- Prev by Date: Re: Draw over other controls
- Next by Date: RE: VB.net Datagridview cellstyle colors
- Previous by thread: ByVal object parameters not modified over Remoting
- Next by thread: Re: Public variable not the same as using a property?
- Index(es):
Relevant Pages
|