Chapter 6. Loops

In previous chapters, we learned how to tell Unity what to do line by line. In most of our examples, we wrote one instruction per line. I want to move on to something a bit more complex now.

In this chapter, we will cover the following topics:

  • Introduction to loops
  • Why we use loops
  • Commonly used loops
  • Loops with statements
  • Searching for data inside a loop
  • Breaking loop execution

Introduction to loops

Loops are an essential technique when writing any software in pretty much any programming language. By using loops, we gain the ability to repeat a block of code X number of times. There are many variants of loops in C#. We will talk about the most common loops:

  • The foreach loop
  • The for loop
  • The while loop
..................Content has been hidden....................

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