Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

Because all value types resolve to reference types in the .NET

Framework, you can just set the variable to Nothing (in VB) or null

(in C#).

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

mocella, i tried your method but I don't think I understood it right. If you can give me an example that would be great.

Bucky, I tried setting the value to nothing but all it does is it sets the variable time to its default that is 12:00:00 AM. thanks

  • *Experts*
Posted

When you access a DateTime variable that has been set to

Nothing, then it will initialize and return the default value. Instead

of retrieving its value, just check to see if it's equal to Nothing.

 

Here x is the DateTime variable:

If x = Nothing Then
 ' x is set to default value
End If

 

Note that for reference types you use the Is keyword to compare

objects. For comparing a value type (x, the DateTime) with a

reference type (Nothing), as is the case here, you use =.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...