Array List - enumeration

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amit Puri

    #1

    Array List - enumeration

    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 OceanMsgXMLTemp lates.Traveller
    If arrTravellers.C ount > 0 Then
    For Each objTraveller In arrTravellers
    If objTraveller.ID = Id Then
    Return True
    End If
    Next
    End If
    End If
    End Function

    Thanks
  • Jon Skeet [C# MVP]

    #2
    Re: Array List - enumeration

    Amit Puri <tc00158@emirat es.com> wrote:[color=blue]
    > 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[/color]

    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.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    Working...