Last post Sep 23, 2012 02:10 PM by Xequence
Sep 19, 2012 01:39 PM|Xequence|LINK
I am using ICOmparable on my object. I am doing a comparison between the objects in the sense that some comparisons are comparing different fields of different objects. This code works, but I am wondering if there is a more smooth approach to doing this?
I am binding readonly property ReplyCount only to give me a value to deduce my comparison logic. Thanks in advance.
Public Function CompareTo(other As DiscussionThread) As Integer Implements System.IComparable(Of DiscussionThread).CompareTo
If Me.ReplyCount > 0 And other.ReplyCount > 0 Then
Dim retVal = other.DiscussionReplies(other.DiscussionReplies.Count - 1).Created_On.Ticks.CompareTo(Me.DiscussionReplies(Me.DiscussionReplies.Count - 1).Created_On.Ticks)
ElseIf Me.ReplyCount > 0 And other.ReplyCount = 0 Then
Dim differentCompare = CDate(other.posteddate).Ticks.CompareTo(Me.DiscussionReplies(Me.DiscussionReplies.Count - 1).Created_On.Ticks)
ElseIf Me.ReplyCount = 0 And other.ReplyCount > 0 Then
Dim differentCompare = DateTime.Compare(other.DiscussionReplies(other.DiscussionReplies.Count - 1).Created_On, CDate(Me.posteddate))
Sep 23, 2012 02:10 PM|Xequence|LINK
I may have not been clear, but the purpose is to compare different object properties. Based on property ReplyCount, is how i set the logic comparison. Is there a cleaner way to achieve this with different objects? Say, better than readonly property?