Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Compare 2 Object Properties On A Class
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01474360
Message ID:
01474365
Views:
37
Because they can hold any type.

>Why do you define them as public properties and of type object? Does Object implement IComparable interface? I doubt it, I think you need to use specific type for these properties.
>
>>I have this class:
>>
>>
>>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;
>>            }
>>        }
>>    }
>>}
>>
>>
>>
>>I'm trying to set IsChanged, but the SetIsChanged method doesn't seem right. I want to compare the values of the OriginalValue and ChangedValue properties.
>>
>>What's the right way to do this?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform