Sideway from Sideway
Draft for Information Only


VB.NET Nothing
 See also

VB.NET Nothing

Represents the default value of any data type. For reference types, the default value is the null reference. For value types, the default value depends on whether the value type is nullable.


For non-nullable value types, Nothing in Visual Basic differs from null in C#. In Visual Basic, if you set a variable of a non-nullable value type to Nothing, the variable is set to the default value for its declared type. In C#, if you assign a variable of a non-nullable value type to null, a compile-time error occurs.


Nothing represents the default value of a data type. The default value depends on whether the variable is of a value type or of a reference type.

A variable of a value type directly contains its value. Value types include all numeric data types, Boolean, Char, Date, all structures, and all enumerations. A variable of a reference type stores a reference to an instance of the object in memory. Reference types include classes, arrays, delegates, and strings. For more information, see Value Types and Reference Types.

If a variable is of a value type, the behavior of Nothing depends on whether the variable is of a nullable data type. To represent a nullable value type, add a ? modifier to the type name. Assigning Nothing to a nullable variable sets the value to null. For more information and examples, see Nullable Value Types.

If a variable is of a value type that is not nullable, assigning Nothing to it sets it to the default value for its declared type. If that type contains variable members, they are all set to their default values.

If a variable is of a reference type, assigning Nothing to the variable sets it to a null reference of the variable's type. A variable that is set to a null reference is not associated with any object.

When checking whether a reference (or nullable value type) variable is null, do not use = Nothing or <> Nothing. Always use Is Nothing or IsNot Nothing.

For strings in Visual Basic, the empty string equals Nothing. Therefore, "" = Nothing is true.

If you declare a variable without using an As clause and set it to Nothing, the variable has a type of Object. An example of this is Dim something = Nothing. A compile-time error occurs in this case when Option Strict is on and Option Infer is off.

When you assign Nothing to an object variable, it no longer refers to any object instance. If the variable had previously referred to an instance, setting it to Nothing does not terminate the instance itself. The instance is terminated, and the memory and system resources associated with it are released, only after the garbage collector (GC) detects that there are no active references remaining.

Nothing differs from the DBNull object, which represents an uninitialized variant or a nonexistent database column.

See also



ID: 200800028 Last Updated: 28/8/2020 Revision: 0 Ref:



  1. Active Server Pages,  ,
  2. ASP Overview,  ,
  3. ASP Best Practices,  ,
  4. ASP Built-in Objects,  ,
  5. Response Object,  ,
  6. Request Object,  ,
  7. Server Object (IIS),  ,
  8. Application Object (IIS),  ,
  9. Session Object (IIS),  ,
  10. ASPError Object,  ,
  11. ObjectContext Object (IIS),  ,
  12. Debugging Global.asa Files,  ,
  13. How to: Debug Global.asa files,  ,
  14. Calling COM Components from ASP Pages,  ,
  15. IIS ASP Scripting Reference,  ,
  16. ASP Keywords,  ,
  17. Creating Simple ASP Pages,  ,
  18. Including Files in ASP Applications,  ,
  19. ASP Overview,  ,
  20. FileSystemObject Object,  ,
  21.,  , ADO Object Model
  22. ADO Fundamentals,  ,

Home 5






Hobbies 8


Chinese 1097

English 337

Reference 67


Hardware 151


Application 198

Digitization 25

Latex 9

Manim 121

Numeric 19


Web 283

Unicode 494


CSS 58


OS 389

DeskTop 7

Python 19



Formulas 8

Algebra 25

Number Theory 206

Trigonometry 18

Geometry 21

Calculus 67

Complex Analysis 21


Tables 8


Mechanics 1

Rigid Bodies

Statics 92

Dynamics 37

Fluid 5

Fluid Kinematics 5


Process Control 1

Acoustics 19

FiniteElement 2


Electric 27

Biology 1

Geography 1

Copyright © 2000-2020 Sideway . All rights reserved Disclaimers last modified on 06 September 2019