When you also use for ... Each loop or a for 1 to Count loop to process the collection, VB. NET has added a new technology, IEnumerator interface.
The IEnumerator interface supports two methods and one feature. The MoveNext method can move one record at a time in the collection. The Reset method enables the enumerator to be reset to the start of the collection. The current attribute can return the present record from the collection.
The following procedure shows the possible methods for these three kinds of calculation sets.
Dim testcollection as New Collection ()
Dim Collectionitem as String
Dim Loopcounter as Integer
Dim Enumcollection as IEnumerator
With Testcollection
. ADD ("1")
. ADD ("2")
. ADD ("3")
End With
For each collectionitem in Testcollection
Console.Out.WriteLine (Collectionitem)
Next
For loopcounter = 1 to Testcollection.count
Console.Out.WriteLine (Testcollection.item (Loopcounter))
Next
Enumcollection = Testcollection.getenumerator ()
Do While Enumcollection.movenext
Console.Out.WriteLine (enumcollection.current)
Loop
IEnumerator bring you for ... The count function provided by each technology, plus new features to make the loop reset and start from the starting position.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service