Difference Between For and Foreach loop
For
1. If you want to access object by Index then use for loop.
2. To use For loop you must have know that how many times loop repeated.
2. To use For loop you must have know that how many times loop repeated.
Foreach
1. if you want to iterate object then use foreach loop.
2. in for each no need to know about total loop repeating.
2. in for each no need to know about total loop repeating.
Performance
wise for loop is faster then foreach.
Comments
Post a Comment