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 / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Order of Items in a collection object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sugandh Jain - 14 Jun 2007 12:20 GMT
Hi,

I am developing using MS Visual Studio .net 2005, c# 2.0.

My query/confusion is as follows:

If I have a collection of a particular type of object.

While moving in the collection using foreach or forloop, will I get the
taxlots in the same order in which they were inserted into the collection.

I want to get them in the same order to update a property which depends on
the sequence in which items were added in the collection.

Regards,
Sugandh
Michael Nemtsev - 14 Jun 2007 12:25 GMT
Hello Sugandh,

Do u need smth like HashList?! http://www.codeproject.com/csharp/hashlistarticle.asp

---
WBR,  Michael  Nemtsev [.NET/C# MVP].  
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

SJ> confusion is as follows:
SJ>
SJ> If I have a collection of a particular type of object.
SJ>
SJ> While moving in the collection using foreach or forloop, will I get
SJ> the taxlots in the same order in which they were inserted into the
SJ> collection.
SJ>
Moty Michaely - 14 Jun 2007 12:26 GMT
On Jun 14, 2:22 pm, "Sugandh Jain" <sugandh.j...@nirvana-sol.com>
wrote:
> Hi,
>
[quoted text clipped - 12 lines]
> Regards,
> Sugandh

Dear Sugandh,

It depends on the type of the collection you choose.

Arrays typically maintain insertion order while Hash tables don't.

I would suggest to use the generic List which maintains the index of
the items.

Hope this helps,
Moty
Sugandh Jain - 14 Jun 2007 14:15 GMT
I did check whether its maintained or not.
it is actually maintained and i have written the code required.
it is actually a list specific to the Type.

Regards,
Sugandh

> On Jun 14, 2:22 pm, "Sugandh Jain" <sugandh.j...@nirvana-sol.com>
> wrote:
[quoted text clipped - 28 lines]
> Hope this helps,
> Moty
Ignacio Machin ( .NET/ C# MVP ) - 14 Jun 2007 15:22 GMT
Hi,

>I did check whether its maintained or not.
> it is actually maintained and i have written the code required.

Unless it's especified in the docs do not assume that. It might change later
on.

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.