Results 1 to 4 of 4

Thread: Difference between for and foreach loop.

  1. #1

    Thread Starter
    Banned
    Join Date
    Jul 2015
    Posts
    14

    Difference between for and foreach loop.

    Hi...everyone can you please describe me what is difference between for and foreach loop.

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: Difference between for and foreach loop.




  3. #3
    Registered User
    Join Date
    Sep 2015
    Posts
    4

    Re: 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....

  4. #4
    New Member
    Join Date
    Jul 2015
    Location
    India
    Posts
    4

    Re: Difference between for and foreach loop.

    For is to perform number of iteration where as foreach used for collection of objects.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width