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.

Foreach

       1.  if you want to iterate object then use foreach loop.
       2.  in for each no need to know about total loop repeating.


Performance  wise for loop is faster then foreach.

Comments

Popular posts from this blog

Display multiple marker point on Google Map with same location or same Longitude,Latitude

Implementing Zoom functionality in asp.net

Check Session Timeot for Whole Application