Enumerate the efficiency with new VB.NET enumeration

zhaozj2021-02-16  57

When you also use for ... EACH loops or for 1 to count cycle processing set, a new technology is added to the IEnumerator interface. The IEnumerator interface supports two methods and features. The MOVENEXT method can move a record in a collection. The reset method enables the enumerator to reset the start of the collection. The Current feature can return the current record from a collection. The following program shows the possible ways of these three calculations. Dim testCollection As New Collection () Dim collectionItem As StringDim loopCounter As IntegerDim enumCollection As IenumeratorWith testCollection.Add ( "1"). Add ( "2"). Add ( "3") End WithFor Each collectionItem In testCollectionConsole.Out.WriteLine ( collectionItem) NextFor loopCounter = 1 To testCollection.CountConsole.Out.WriteLine (testCollection.Item (loopCounter)) NextenumCollection = testCollection.GetEnumerator () Do While enumCollection.MoveNextConsole.Out.WriteLine (enumCollection.Current) Loop IEnumerator bring you For ... The count function that EACH technology can provide, and there is also a new feature that causes the loop reset and starting from the starting position.

转载请注明原文地址:https://www.9cbs.com/read-22788.html

New Post(0)