>>>public class ReportColumn >>>{ >>> public string ColumnName { get; set; } >>> public object OriginalValue { get; set; } >>> public object ChangedValue { get; set; } >>> public bool IsChanged { get; private set; } >>> >>> public void SetIsChanged() >>> { >>> IsChanged = false; >>> >>> PropertyInfo[] sourceProperties = OriginalValue.GetType().GetProperties(); >>> foreach (PropertyInfo pi in sourceProperties) >>> { >>> object originalProperty = OriginalValue.GetType().GetProperty(pi.Name).GetValue(this, null); >>> object changedProperty = ChangedValue.GetType().GetProperty(pi.Name).GetValue(comparisonObject, null); >>> >>> IsChanged = (originalProperty != changedProperty); >>> >>> if (IsChanged) >>> { >>> break; >>> } >>> } >>> } >>>} >>> >>>>>>
object originalProperty = OriginalValue.GetType().GetProperty(pi.Name).GetValue(OriginalValue, null); object changedProperty = ChangedValue.GetType().GetProperty(pi.Name).GetValue(ChangedValue, null);But, even assuming the two objects are of the same type, that still won't work because you are comparing objects and the default behaviour of == is to return reference equality (i.e. it will only be true if the objects being compared are the same instance)