About using inderface IComparable

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

When this method foo is called parameter car is passed. When this Sort in
the Array class is called is it nessesary
that all cars is of the same type. I know that the IComparable interface
must be implemented but could the
vector car contains SAAB, VOLVO, PORCHE and FORD.

I mean can this CompareTo method compare between different classes.

public static void foo( Car[] car )
{
Array.Sort(temp);
}

//Tony
 
I mean can this CompareTo method compare between different classes.

Yes it can.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top