As itsmatt has said your first snippet is doing a reference comparison. An alternative to calling ToString is to use Object. Equals : if (Object.
Equals(dt1. Rows0"Name", dt2. Rowsb"Name")) { // stuff } The reason for using the static method instead of the instance method is to avoid problems with null references.
As itsmatt has said, your first snippet is doing a reference comparison. An alternative to calling ToString is to use Object. Equals: if (Object.
Equals(dt1. Rows0"Name", dt2. Rowsb"Name")) { // stuff } The reason for using the static method instead of the instance method is to avoid problems with null references.
Thanks for the answer and code sample. I didn't really want to use .ToString(), it didn't feel right somehow :) – GateKiller Mar 5 '09 at 13:29.
Those cells hold objects so you are doing an object comparison, which just does a reference comparison, which is different from a value comparison. It asks the question "Are these two objects really the same object? ", essentially are they referring to the same object, hence "reference comparison".
When you do the ToString() call, you are then doing string comparison. That is why it works. Here's a link to MS's discussion of Operator== and comparison.
Thanks. Is there any work around or is .ToString() the best I can do? – GateKiller Mar 5 '09 at 13:22 To add: if you cast both sides to string, it will work too.
– leppie Mar 5 '09 at 13:22.
The == operator, if not overloaded, is identical to ReferenceEquals() -- that is, it determines whether two given objects are the same instances. The call to ToString() returns an object of string class, which has overloaded == operator, which does string comparison.
1, very good explanation – muerte Mar 5 '09 at 13:24 Important: it's not an overridden == operator, it's an overloaded operator. – Jon Skeet Mar 5 '09 at 13:24 @Jon Skeet -- Very true, thanks. Edited.
– Anton Gogolev Mar 5 '09 at 13:28 Thanks for explaining why my first method didn't work :) – GateKiller Mar 5 '09 at 13:31.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.