I'm trying to create a generic "property" class that maintains both it's current value and the last value.
public class GenericTrackingProperty<T> where T : IEquatable<T>
{
private T _oldValue;
private T _currentValue;
public T Value
{
get { return _currentValue; }
set
{
if (value != _currentValue)
{
_oldValue = _currentValue;
_currentValue = value;
}
}
}
}
Despite the use of the where in the class definition to ensure the generic type is equatable the compiler complains about the comparison "if (value != _currentValue" giving an error "Operator '!=' cannot be applied to operands of type 'T' and 'T'". What am I doing wrong?