Re: Nullable object types
- From: "Patrice" <scribe@xxxxxxxx>
- Date: Mon, 21 Aug 2006 14:58:49 +0200
As I said, you also have to correctly type your property :
Private _ID As Nullable(Of Integer)
Public Property ID() As Nullable(Of Integer)
Get
Return _ID
End Get
Set(ByVal value As Nullable(Of Integer))
_ID = value
End Set
End Property
You can then set the property to nothing :
Me.ID = 1234
Me.ID = Nothing
MsgBox(Me.ID.HasValue)
--
Patrice
"Nemisis" <darrens2005@xxxxxxxxxxx> a écrit dans le message de news:
1155923166.441551.104540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Patrice wrote:
Try :I have tried setting the property to nothing and that still doesnt
Me.ID = Nothing
MsgBox(Me.ID.HasValue)
Use Option Strict so that youi see you should make the propery
IsNullable(Of
Integer) instead of just Object...
--
Patrice
"Nemisis" <darrens2005@xxxxxxxxxxx> a écrit dans le message de news:
1155915967.692120.253820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi everyone, i have been stressing over this for the past hour or so,
and just cannot figure it out, sorry if i am being stupid, but it is a
friday! lol
I have the following
Private _ID as nullable (Of integer)
Public Property ID()
Get
Return _ID
End Get
Set(ByVal value)
_ID = value
End Set
End Property
If i write
Me.ID = 1234
then the value in the debugger seems to update, great.
But how do i get it back to null again? If i set ID = DBNull.Value, i
get a build error. If i set ID = Nothing, then in the debugger, it
says "Nullable object must have a value".
If i am missing the point and being stupid, i do apoligise, i just
really need to get this done.
work. ???
.
- References:
- Nullable object types
- From: Nemisis
- Re: Nullable object types
- From: Patrice
- Re: Nullable object types
- From: Nemisis
- Nullable object types
- Prev by Date: CSS problem under ASP.NET
- Next by Date: Re: Dataset using MySql renders "Parser Error"
- Previous by thread: Re: Nullable object types
- Next by thread: dynamic dataformatstring in a gridview
- Index(es):
Relevant Pages
|