[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

object values appearing the same arent equal

Posted on 2008-06-16
3
Medium Priority
?
249 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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