A pedant that hangs out in the dark corner-cases of the web.

Tuesday, July 13, 2004

Nothing is really something in VB.NET

In VBScript, there were Empty (no value, initial value of all variables), Null (a third logical state), and Nothing (a non-object). IsEmpty, IsNull, and IsNothing tested for these values.

In VB.NET, Nothing is a keyword that actually means "default", and IsNothing checks for object assignment:

Public dt as DateTime

dt= Nothing
Console.WriteLine(IsNothing(dt)) ' FALSE!
Console.WriteLine(dt = #00:00#) ' True

The .NET docs imply that Nothing replaces Empty, though this is clearly not the case.

No comments: