B
Brian W
Because of the upcoming US holiday I'll probably have to ask this again next
week, but just on the off-chance, I'll ask anyway
I have a class defined something like this...
public class Item : IComparable
{
private string _name;
// ... more stuff here
public int CompareTo(object obj)
{
// I put a break point below to test this...
return _name.CompareTo(((Item)obj)._name;
}
}
Then. elsewhere I have an array of Item
Item[] items = new Item[5];
//Fill the array blah, blah, blah
Now, when I want to sort I do this...
Array.Sort(items);
and voila! the array is sorted, and in doing so, the break point is hit in
the CompareTo method
OK, let's say I wanted it Reverse sorted so I do this...
Array.Reverse(items);
I get no errors or exceptions and the array is returned to me in the same
state/order it went in.
AND the break point is never hit in CompareTo
Am I doing something wrong or is Reverse broken, or am I completely
misunderstanding something.
TIA
Brian W
week, but just on the off-chance, I'll ask anyway
I have a class defined something like this...
public class Item : IComparable
{
private string _name;
// ... more stuff here
public int CompareTo(object obj)
{
// I put a break point below to test this...
return _name.CompareTo(((Item)obj)._name;
}
}
Then. elsewhere I have an array of Item
Item[] items = new Item[5];
//Fill the array blah, blah, blah
Now, when I want to sort I do this...
Array.Sort(items);
and voila! the array is sorted, and in doing so, the break point is hit in
the CompareTo method
OK, let's say I wanted it Reverse sorted so I do this...
Array.Reverse(items);
I get no errors or exceptions and the array is returned to me in the same
state/order it went in.
AND the break point is never hit in CompareTo
Am I doing something wrong or is Reverse broken, or am I completely
misunderstanding something.
TIA
Brian W