What's the equivalent of Nothing?

Published 12 March 04 02:26 AM

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]

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Joku said on March 14, 2004 12:49 AM:
if (bool) // checks for bool=true

why

if (notvaluetype) // can't check for null, instead complains not being bool ? i find this very annoying
# Jon Skeet said on March 15, 2004 1:32 AM:
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
# ok said on July 18, 2004 12:26 AM:
my web:
http://www.sj55.com/pic_sort http://www.zw88.com/paopaotang.htm http://www.zw88.com/sj.htm http://www.zw88.com/sm/
http://www.zw88.com/sms/ http://www.zw88.com/zw.htm http://www.resou.com/8888.htm http://www.sj55.com/pic/pic_1130.htm
# RebelGeekz said on December 28, 2004 4:54 AM:
[http://itpeixun.51.net/][http://aissl.51.net/][http://kukuxz003.freewebpage.org/][http://kukuxz001.51.net/][http://kukuxz003.51.net/][http://kukuxz005.51.net/][http://kukuxz002.51.net/][http://kukuxz004.freewebpage.org/][http://kukuxz007.51.net/][http://kukuxz001.freewebpage.org/][http://kukuxz006.51.net/][http://kukuxz002.freewebpage.org/][http://kukuxz004.51.net/][http://kukuxz008.51.net/][http://kukuxz009.51.net/][http://kukuxz005.freewebpage.org/][http://kukuxz006.freewebpage.org/][http://kukuxz007.freewebpage.org/][http://kukuxz009.freewebpage.org/]

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

This Blog

Syndication

Page view tracker