logo       

Re: Moving object order in a collection in C#: msg#00048

Subject: Re: Moving object order in a collection in C#
Look into using a SortedList (Dictionary sorted by the key)

If you need more complex logic, so that you can sort other than by 
just the key, look at IComparer and IComparable...

I posted this earlier via yahoo's website, but for some reason it's 
really slow today, so I'm trying again...


--- In padnug@xxxxxxxxxxxxxxx, "Keith R. Pinster" <dimondwoof@xxxx> 
wrote:
> I've got an object that has a set of sub-objects.  I want to be 
able to 
> retrieve the sub-objects in a certain order.  Is there a way to 
change 
> the index of the sub-objects?
> 
> E.G:
> Favorites:
> Cars:
>  1. Corvette
>  2. Nova
>  3. Firebird
> 
> User wants to change the order so that it reads:
>  1. Corvette
>  2. Firebird
>  3. Nova
> 
> Currently I'm tracking the order with an Order int field, but this 
> seems really messy and error prone.  Any ideas?




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12hcjnvgo/M=362335.6886445.7839731.1510227/D=groups/S=1705007709:TM/Y=YAHOO/EXP=1124836595/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/";>In
 low income neighborhoods, 84% do not own computers. At Network for Good, help 
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~-> 

 


<Prev in Thread] Current Thread [Next in Thread>