Array List - enumeration

G

Guest

Please help me in the understanding functioning of an arraylist:


I've having an arraylist function level, which I'm looping another object,
and check the values of arraylist for existance with this looped object. So
i'm passing the value of this object with the arraylist in another function
(byval)and looping through the arraylist, and checking this object value.

and i've getting this message:
enumeration already finished

according to my understanding when i pass the arraylist in another function,
it is not retain the state of the iteration of last function call. and it
should start from the beginning. then why i'm getting 'enumeration already
finished'. when i can see arraylist count>0.

It seems i'm not clear about the object values passing in the function
(byval) in .net

please help in understanding the same.

Code snippnet is here

Public Function TravellerExists(ByVal arrTravellers As ArrayList, ByVal Id
As String) As Boolean
If Not arrTravellers Is Nothing Then
Dim objTraveller As OceanMsgXMLTemplates.Traveller
If arrTravellers.Count > 0 Then
For Each objTraveller In arrTravellers
If objTraveller.ID = Id Then
Return True
End If
Next
End If
End If
End Function

Thanks
 
J

Jon Skeet [C# MVP]

Amit Puri said:
Please help me in the understanding functioning of an arraylist:


I've having an arraylist function level, which I'm looping another object,
and check the values of arraylist for existance with this looped object. So
i'm passing the value of this object with the arraylist in another function
(byval)and looping through the arraylist, and checking this object value.

and i've getting this message:
enumeration already finished

It's not clear to me why you're getting that - could you post a short
but complete program which demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.
 

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