Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / November 2003

Tip: Looking for answers? Try searching our database.

Need an expression to check whether an object is null in the debugger

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Casey - 23 Sep 2003 21:05 GMT
In VS .NET (2002), how can you check whether an object is null in the
debugger (Watch window)?

The following expression evaluates correctly...

myString == string.Empty

...however, this expression produces "error: unable to evaluate expression"

myString == null

Any ideas why?  Is there another way to check whether an object is null?

Thanks,
Casey
Me - 29 Sep 2003 14:33 GMT
Does it produce that error regardless of whether myString actually is null?
If not, you have your answer. BTW string being empty, i.e., "", is different
from null.
Signature

Jim
"Remember, an amateur built the Ark; professionals built the Titanic."

> In VS .NET (2002), how can you check whether an object is null in the
> debugger (Watch window)?
[quoted text clipped - 11 lines]
> Thanks,
> Casey
Casey - 29 Oct 2003 23:56 GMT
I want to set a breakpoint that conditionally breaks if an object is null.
However, I have not been able to find any syntax that allows me to do this.
When I try to compare the object to null, VS .NET says it is invalid syntax.

> Does it produce that error regardless of whether myString actually is null?
> If not, you have your answer. BTW string being empty, i.e., "", is different
[quoted text clipped - 19 lines]
> > Thanks,
> > Casey
Nick Savoiu - 30 Oct 2003 02:09 GMT
Did you try comparing with 0?

Nick

> I want to set a breakpoint that conditionally breaks if an object is null.
> However, I have not been able to find any syntax that allows me to do this.
[quoted text clipped - 25 lines]
> > > Thanks,
> > > Casey
Casey - 05 Nov 2003 22:40 GMT
Yes, I did.  It evaluates to false regardless of whether it is null or not.

> Did you try comparing with 0?
>
[quoted text clipped - 32 lines]
> > > > Thanks,
> > > > Casey
Nick Savoiu - 06 Nov 2003 00:12 GMT
that doesn't sound right... what was the condition that you were breaking
on?

nick

> Yes, I did.  It evaluates to false regardless of whether it is null or not.
>
[quoted text clipped - 36 lines]
> > > > > Thanks,
> > > > > Casey
Casey - 07 Nov 2003 23:08 GMT
I have code like this...

object o = null;
int i = 3;  // set a breakpoint here
int j = 5;  // want to set a conditional breakpoint here; only want to break
here if o is null

In the visual studio .NET watch window, type the expression "o == 0".  It
evaluates to false even though o is null.  If I just watch the object o, the
watch window says it is null.  However, I can't find an expression that will
allow me to compare an object vs null, therefore I can't conditionally break
if the object is null.

> that doesn't sound right... what was the condition that you were breaking
> on?
[quoted text clipped - 44 lines]
> > > > > > Thanks,
> > > > > > Casey

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.