Re: Public variable not the same as using a property?
- From: "Armin Zingler" <az.nospam@xxxxxxxxxx>
- Date: Fri, 14 Sep 2007 15:38:09 +0200
"dgk" <dgk@xxxxxxxxxxxxx> schrieb
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.
No, it doesn't convert anything. The first is a public field, the second a property.
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?
Probably a missing feature that it can not bind to public fields.
Armin
.
- Follow-Ups:
- Re: Public variable not the same as using a property?
- From: Cor Ligthert[MVP]
- Re: Public variable not the same as using a property?
- References:
- Prev by Date: RE: VB.net Datagridview cellstyle colors
- Next by Date: Re: Public variable not the same as using a property?
- Previous by thread: Public variable not the same as using a property?
- Next by thread: Re: Public variable not the same as using a property?
- Index(es):
Relevant Pages
|