-
comparing values
Is there an easy and quick way to compare values of 2 objects?
I have a function that accepts 2 parameters of object type.
I want to see if the values are the same or different.
The 2 objects will always be of the same type.
however the function can be called from many places and different types can be passed in.
The objects can also be nothing at times.
Thanks,
-
Re: comparing values
How can the system possibly know how to compare two objects unless you tell it? If a type implements the IComparable interface then its author has already told the system how to compare two objects of that type. In that case there IS an easy way to compare them. Otherwise there isn't. In that case you would have to write your own code to compare two instances of each type you might want to compare.
-
Re: comparing values
John is correct. The only way you can just do a standard equals using the object base class is to check for reference equality, but I am sure that is not what you are looking to do.
Otherwise you need to write code to determine how to check for equality