Looping though lists to make decisions

These previous array, List, and Dictionary examples showed how to get data into them, and how they store data. It's now time to learn how to loop through the data to retrieve the needed data.

Here are some common ways to perform loops:

  • foreach loop
  • for loop
  • while loop

Using the foreach loop

When working with Collections such as an array, a list or dictionary, the preferred way to cycle through the elements and retrieve data is to use the foreach loop.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.159.223