c#abstract class
C #. NET in general three ways to scan through each element of a collection c#abstract class. The process of scanning through a collection called iteration.
The basic and most common form of the iteration via a loop .c#abstract class Most programmers have used at one time or another . An example of a loop is as follows :
for (int i = 0; i < 10; i + +)
For - loops are straightforward to browse a collection forms.c#abstract class Allow flexibility so it is very easy to change increments i . The only drawback is that the collection of C # should support the access rate , otherwise the loop is useless in the iteration.
The second way is to use a foreach loop. A foreach loop is less technical ,c#abstract class so to speak , it does not use an index to access elements :
For (int i in myCollection )
Foreach loops are easier to read. The disadvantage is that the programmer does not have direct access to elements of a collection while moving , c#abstract class which means that the developer can not modify the elements. The advantage is that the collection of C # does not support access indices. All it takes is an enumerator .
This leads to the third type of iteration: the use of an enumerator .c#abstract class The enumerator is an abstract class that provides basic access to the elements of a list of functions .c#abstract class The two main functions are MoveNext ( which moves the enumerator to the next element in the collection ) and the current property (which returns the current enumerator element is accessible) .
Enumerators are nice because they are very abstract . c#abstract class They are useful when you do not know much about the structure of the collection was repeated . c#abstract class It also eliminates the need to index and provides more control than a foreach loop.
Labels:
c#abstract class
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment