Hi...everyone can you please describe me what is difference between for and foreach loop.
Printable View
Hi...everyone can you please describe me what is difference between for and foreach loop.
for is used to iterate the items in built in types( like Array ..) not used for user defined types (like Class...).
foreach is used to iterate over collections of objects in class , i.e. User defined type.....
Both Plays an important role in programming,as a programmer we have to choose which is best for the situation....
For is to perform number of iteration where as foreach used for collection of objects.