E
Erick
I have a generic comparer class that i use to help me sort collections
of any object in any order.
It worked with Option strict off but now i need it to work with option
strict on.
Here is some of the code
Public Function Compare(ByVal x As Object, ByVal y As Object) As
Integer Implements System.Collections.IComparer.Compare
Dim prop As Reflection.PropertyInfo =
x.GetType.GetProperty(Me.SortProperty)
If Me.SortOrder = SortOrderEnum.None OrElse
object.Equals(prop.GetValue(x, Nothing),prop.GetValue(y, Nothing) Then
Return 0
Else
If prop.GetValue(x, Nothing) > prop.GetValue(y, Nothing)
Then
The last line won't work as X and Y are objects and you can't compare
objects with the > operand with option strict turned on.
Is there some way i can use Reflection to find the type and cast the
type in the If statement so i can check to see if one value is greater
than another ?
Any help appreciated.
of any object in any order.
It worked with Option strict off but now i need it to work with option
strict on.
Here is some of the code
Public Function Compare(ByVal x As Object, ByVal y As Object) As
Integer Implements System.Collections.IComparer.Compare
Dim prop As Reflection.PropertyInfo =
x.GetType.GetProperty(Me.SortProperty)
If Me.SortOrder = SortOrderEnum.None OrElse
object.Equals(prop.GetValue(x, Nothing),prop.GetValue(y, Nothing) Then
Return 0
Else
If prop.GetValue(x, Nothing) > prop.GetValue(y, Nothing)
Then
The last line won't work as X and Y are objects and you can't compare
objects with the > operand with option strict turned on.
Is there some way i can use Reflection to find the type and cast the
type in the If statement so i can check to see if one value is greater
than another ?
Any help appreciated.