coder316 said:
When I call this:
Array.Sort(blah);
This gets run:
public int CompareTo(object obj) // Implement the method.
{
MyClass mc = (MyClass)obj;
if (this.TheValue < mc.TheValue) return -1;
if (this.TheValue > mc.TheValue) return 1;
return 0;
}
I know theres a heirarchy of calls being made, but I cant find hem.
Anybody with an Explanation?
It's difficult to provide an exact explanation without knowing exactly
what your experience level is, and what your specific question is. But,
making some assumptions:
-- When you call Array.Sort(), that method has to do comparisons
between the elements of the array
-- One way to define a comparison between objects is to implement
IComparable
-- Through the magic of polymorphism, each time Array.Sort() wants
to know whether a given object is "less than", "greater than", or "equal
to" another given object, and those objects implement IComparable,
Array.Sort() can just cast the object reference to IComparable and call
the CompareTo() method in that interface.
Depending on how much you know about sorting algorithms and
polymorphism, the above may or may not make sense. Also depending on
what your actual question is, the above may or may not actually address
what you're asking.
I'm also not clear on why you are asking about the object browser. If
you're looking for "a hierarchy of calls", that's a run-time thing that
you can look at in the debugger. But the object browser doesn't know
anything about that. It just shows you the members of classes and the
relationships between class _declarations_, not run-time relationships
related to the execution of code.
If the above doesn't answer the question, you should consider trying to
be more specific, rephrasing the question so it's more clear exactly
what you don't understand.
Pete