Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Nothing equal to Default?

Tags:

vb.net

What happens when i set a variable to nothing in VB.NET? Is it true that nothing equals to default, or am i missing something here?

like image 241
OrElse Avatar asked Dec 18 '22 04:12

OrElse


1 Answers

If it's a value type (like Integer, Double, etc.) setting the variable to Nothing will set it to the default value.

If it's a reference type, it will really be set to Nothing (null value).

In Microsoft's words:

Assigning Nothing to a variable sets it to the default value for its declared type.

If the variable is of a reference type, a value of Nothing means that the variable is not associated with any object. The variable has a null value.

like image 57
Meta-Knight Avatar answered Jan 11 '23 11:01

Meta-Knight