Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / May 2004

Tip: Looking for answers? Try searching our database.

ArrayList Sort Terminating

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BobTheHacker - 13 May 2004 14:51 GMT
Project C# utilizing the Framework

In my project I have an array list of integers that sorts just fine.  Then I have an array list that contains a class that I have built.  When I call the "sort" method of the array list and accept the defualt sort arraylist.sort() I get the following error message: "At least one object must implement IComparable.".     Does this mean I am going to have to override the compare function and implement my own compare to function for the sort ?
Fabian Schmied - 13 May 2004 14:59 GMT
BobTheHacker schrieb:

> Project C# utilizing the Framework.
>
[quoted text clipped - 5 lines]
> am going to have to override the compare function and implement my
> own compare to function for the sort ?

Not override, implement. Your class should implement the IComparable
interface. How else could the sort algorithm know how to order the
objects of the class?

Fabian
cody - 17 May 2004 19:06 GMT
You can also use the sort method which takes a IComparator as parameter.

Signature

cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk

> BobTheHacker schrieb:
>
[quoted text clipped - 13 lines]
>
> Fabian
Gang Peng - 27 May 2004 05:21 GMT
IComparator is a java thing.
IComparer is the .Net type.

Gang Peng
[MSFT]

> You can also use the sort method which takes a IComparator as parameter.
>
[quoted text clipped - 15 lines]
> >
> > Fabian

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.