About using inderface IComparable

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
 
M

Mattias Sjögren

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

Top