Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2008, 01:16 PM
Authorized User
 
Join Date: Sep 2003
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.
 
Old June 8th, 2008, 02:00 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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.





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





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