C# Frequently Asked Questions

The C# team posts answers to common questions

What's the equivalent of Nothing?

For reference types, the equivalent of VB's Nothing is C#'s null. For value types, it's the default value - 0, false, etc.

[Author: Jon Skeet]

Published Friday, March 12, 2004 2:26 AM by CSharpFAQ

Comments

 

Joku said:

if (bool) // checks for bool=true

why

if (notvaluetype) // can't check for null, instead complains not being bool ? i find this very annoying
March 14, 2004 12:49 AM
 

Jon Skeet said:

It's *great* not to allow "if" to work on anything other than bool, in my view. It means there's no point in writing comparisons the "wrong" way round as you sometimes see in C/C++:

if (5==x)

The above is to avoid the typo of:

if (x=5)

- but in C# the latter doesn't compile anyway.

Jon
March 15, 2004 1:32 AM
 

ok said:

July 18, 2004 12:26 AM
 

RebelGeekz said:

December 28, 2004 4:54 AM
Anonymous comments are disabled

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker