Solved

object values appearing the same arent equal

Posted on 2008-06-16
3
194 Views
Last Modified: 2010-04-15
Hi:

  In the debugger I can see that the values of two objects look the same but when I do o1 == o2 this doesnt seem to hold true. I am tearing my hair out. Any clue why this would be the case. The

DataRow[] r = datatable.Select("ROWKEY=" + x);
Object o1 = r[0][columnName];                                     // original value
Object o2 = db2cmd.Parameter[columnName].Value;  //new value

if (o1 == o2)
{

}
 

0
Comment
Question by:LuckyLucks
3 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21799267
do something like this to see if you can get more one what those objects are:
Response.Write("o1: " + o1.ToString() + "<br />");

Response.Write("o2: " + o2.ToString() + "<br />");

Response.Write("o1 GetType: " + o1.GetType().ToString() + "<br />");

Response.Write("o2 GetType: " + o2.GetType().ToString() + "<br />");

Open in new window

0
 
LVL 10

Accepted Solution

by:
margajet24 earned 500 total points
ID: 21799305
try :

o1.Equals(o2)

since objects are refence type, they can have same values but their memory location is different..

check their value not their reference..
0
 

Author Comment

by:LuckyLucks
ID: 21813614
I am curious about the explanation. If o1 == o2 compares the mem location then they should never be equal during the run of the program. But in some cases they are. Can you explain this?
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now