Compare values from two datasets

  • Thread starter Thread starter Ondrej Sevecek
  • Start date Start date
O

Ondrej Sevecek

Hello,
I would like to compare two values in different datasets with no previous
knowledge of their type nor format...

dataset1.Tables[5].Rows[10]["CollumnName"] = =
dataset2.Tables[3].Rows[8]["OtherCollumn"]

Ondra.
 
Will this suffice for your purposes

dataset1.Tables[5].Rows[10]["ColumnName"].equals(dataset2.Tables[3].Rows[8]["OtherColumn"])
 
I thought that Equals() compares object pointer values, not contents of the
field, doesn't it?

Ondra.


Blake said:
Will this suffice for your purposes?
dataset1.Tables[5].Rows[10]["ColumnName"].equals(dataset2.Tables[3].Rows[8][
"OtherColumn"])
 
I don't think so. I believe Equals() is something that can actually be overridden so that each object can define its own implementation of Equals().

I just ran a test where I filled two different DataSets with the same query from the database, and the following expression retruns true:

dataSet1.Tables[0].Rows[0]["TestTableID"].Equals(dataSet2.Tables[0].Rows[0]["TestTableID"])
 
Hi,

Equals should do the same as == operator.
Excerpt from help:
a.. Override the Equals method whenever you implement ==, and make them do
the same thing. This allows infrastructure code such as Hashtable and
ArrayList, which use the Equals method, to behave the same way as user code
written using ==.

--
Miha Markic - RightHand .NET consulting & software development
miha at rthand com

Blake said:
I don't think so. I believe Equals() is something that can actually be
overridden so that each object can define its own implementation of
Equals().
I just ran a test where I filled two different DataSets with the same
query from the database, and the following expression retruns true:
dataSet1.Tables[0].Rows[0]["TestTableID"].Equals(dataSet2.Tables[0].Rows[0][
"TestTableID"])
 
Back
Top