C#.Net tutorial in Telugu – Control Structures – foreach loop | ottit



#ottit
C#.Net tutorial in Telugu – Control Structures – foreach loop – ottit
When each value of a group or collection need to be processed then foreach is the best.
Availability of values in the collection is the criteria to continue loop each time.
Automatically picks the first item and ends the loop after picking the last item in the collection.
Automatic continuous access from starting item to end item in the collection.
Data type of the value could be of any type i.e. value type or reference type.
More useful while processing arrays and collections.
When we don’t know about the size and type of collection , then also foreach is more useful.
Random access is not possible and accessing set of values based on their position (range like array , by taking start and end positions or index)is not possible by foreach.