Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 8th, 2008, 01:16 PM
Authorized User
 
Join Date: Sep 2003
Location: Orange County, CA, USA.
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to julianfraser Send a message via MSN to julianfraser Send a message via Yahoo to julianfraser
Default isNot nothing vs. string.empty

I have a page load event that contains an if statement relating to a querystring.

I have been using...
If Request.QueryString("orgID") <> String.Empty Then

But I see on page 411 of Beginning ASP.NET 3.5 that Imar uses...
If Request.QueryString("orgID") IsNot Nothing Then

Is there any reason to use one over the other? In my experience, both work.
Reply With Quote
  #2 (permalink)  
Old June 8th, 2008, 02:00 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Julian,

Yes, both work in VB, so you can choose either.

I prefer to use IsNot Nothing, as it more closely resembles its C# counterpart, where comparing with String.Empty doesn't work. In C# you get null when the query string field doesn't exist which isn't equal to String.Empty. It also looks a little better, as a missing query string parameter feels like null / Nothing, not an empty string (which would indicate the param was there, but without a value).

Somehow, in C#

null != String.Empty

where in VB:

Nothing = String.Empty

Feel free to choose the one you like; both work fine.

Cheers,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
empty string Vince_421 VB Databases Basics 2 October 29th, 2008 03:24 PM
Is String.Empty spinout ASP.NET 2.0 Basics 6 July 10th, 2007 05:55 AM
Difference between null and empty string shoakat Classic ASP Databases 4 September 10th, 2004 11:40 AM
Checking for empty string richw32001 General .NET 1 August 8th, 2004 01:37 PM
Convert empty string to double adriant42 Excel VBA 2 June 8th, 2004 04:22 AM



All times are GMT -4. The time now is 07:49 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.