I have the following code in order to compare a value read from a DB with some expected values:
object o = row.get_Value(fieldIndex);
bool equal = o == "mytext";
When I debug that o
has the value "mytext"
. However the comparison yields false
. If on the other hand I cast o
to string
, the comparison works:
bool equal = (string)o == "mytext";
While row
is a COM-object, o.GetType()
returns string
.
Unfortunately I cannot provide what get_Value
does, as I don´t have its sourcecode.
So why does the second comparison work while the first one does not?