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.