P
paolo.ponzano
Hello,
I've to implement a IComparer in order to sort an arraylist.
I've used reflection to get the object I need to sort, at the moment
I'm using the following piece of code:
public int Compare(object x, object y)
{
int i = 0;
object c = getIvar(x, listaOrdinamento[0].ToString());
object d = getIvar(y, listaOrdinamento[0].ToString());
i = c.ToString().CompareTo(d.ToString());
return i;
}
is there better way of doing that?
Have I to check the type of c and d and do the compare based on type?
or does the .ToString() cover all the cases?
Thanks
Bests
Paolo
I've to implement a IComparer in order to sort an arraylist.
I've used reflection to get the object I need to sort, at the moment
I'm using the following piece of code:
public int Compare(object x, object y)
{
int i = 0;
object c = getIvar(x, listaOrdinamento[0].ToString());
object d = getIvar(y, listaOrdinamento[0].ToString());
i = c.ToString().CompareTo(d.ToString());
return i;
}
is there better way of doing that?
Have I to check the type of c and d and do the compare based on type?
or does the .ToString() cover all the cases?
Thanks
Bests
Paolo