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 / June 2004

Tip: Looking for answers? Try searching our database.

BUG? Object comparison in code and debug watch window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guogang - 25 Jun 2004 02:59 GMT
My environment: VS .NET 2003 Version 7.1.3088

When I try to compare two objects which have same basic type like this:

//row is a DataRow object, both columns are integer type with same value
System.Debug.Write(row["title_id"] == row["book_title_id"]);

The C# actually runs and give a "False" result althghou these two column
have the same integer value. However, (very frustrating), the watch window
will show that "row["title_id"] == row["book_title_id"]" evaluates to true.

Is it a bug, or some sort of special design here?

Thanks,
Guogang
Carlos J. Quintero [MVP] - 25 Jun 2004 09:41 GMT
I have seen differences evaluating conditions between the compiled code and
the windows of the debugger, but I still don?t know why they happen.

Signature

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)

> My environment: VS .NET 2003 Version 7.1.3088
>
[quoted text clipped - 11 lines]
> Thanks,
> Guogang
Jason - 28 Jun 2004 12:43 GMT
its an object compairson - you need to unbox for equality testing of int

> My environment: VS .NET 2003 Version 7.1.3088
>
[quoted text clipped - 11 lines]
> Thanks,
> Guogang
Guogang - 29 Jun 2004 18:37 GMT
So, you believe the debug watch window showing "true" for the comparison is
correct behavior?

> its an object compairson - you need to unbox for equality testing of int
>
[quoted text clipped - 14 lines]
> > Thanks,
> > Guogang
Jason - 30 Jun 2004 12:29 GMT
depends what you are comparing

i would think that your c# code is more wrong. your c# code reads to me
object.ReferenceEquals(... - which given the 99.99999999999% liklihood that
you are probably intending on doing a data compairson - is wrong.

i have never considered the debug window to be quite the same as my running
c# code - i accept it as being a window into my running application - not an
object.ReferenceEquals window - but still - i take your point.

> So, you believe the debug watch window showing "true" for the comparison is
> correct behavior?
[quoted text clipped - 18 lines]
> > > Thanks,
> > > Guogang

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.