lundi 9 mars 2015

Comparing values after ChangeType not working

I have the problem, that comparing values after changing the type (in this case to int) does not work:


enter image description here


In my point of view (see the debugger), _pkValue and _defaultValue are both integers with the same value.


The problem is, that the if-statement should not be entered, because both values are 0.


I'm sure it is a very simple thing, but i can't figure it out.


EDIT: Code



object pkVal = pks.First().Value.GetValue(this, null);

if (pkVal != null)
{
var defaultValue = TypeHelper.GetDefaultValue(pkVal.GetType());

var _pkValue = Convert.ChangeType(pkVal, pkVal.GetType());
var _defaultValue = Convert.ChangeType(defaultValue, pkVal.GetType());

if (_pkValue != _defaultValue)
{
canset = false;
}
}


Thank you!


Aucun commentaire:

Enregistrer un commentaire