Jump to content
Xtreme .Net Talk

Recommended Posts

Guest MrPolite
Posted

kinda, you use that instead of null

 

There is a function calls DbNull or isDBNull or something, I cant remember exactly. Sometimes you can use that too, but I think you can do everything with Nothing

Posted

it said that I could also check for nothing by using something like

 

If x Is Nothing Then
or
If IsNothing(x) Then

 

When is the best time to use nothing as a value for a variable? Is there any good time to using "" ?

Posted
I was reading further and it stated that when an object is set to nothing it is set aside for garbage collection. And when the garbage collector comes by the object will be destroyed and its resources will be available again. I thought that null was a good way to give something a blank value but not for destroying the object. What is .NET's way of giving an object a null value without destroying the object?
Guest MrPolite
Posted
I was reading further and it stated that when an object is set to nothing it is set aside for garbage collection. And when the garbage collector comes by the object will be destroyed and its resources will be available again. I thought that null was a good way to give something a blank value but not for destroying the object. What is .NET's way of giving an object a null value without destroying the object?
you dont have to distroy all the objects. If your object is going out of scope then you are fine.

Sometimes your class may lock a resource and you will have to destroy it as soon as possible. You could force garbage collection, but most of the classes (like the graphic class) that are like this have a Dispose method. I think that frees the resources used by that class.....

I think you can also set your object to Nothing

 

and about when to use Nothing: you use that to check the the value of reference-types, like classes. And you have to use the Is operator if you are using Nothing.

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...