1. 1
    You want to write a program that keeps track of the heights of different plants in your garden. You could do this as a series of variables, but those would become difficult to work with really fast…
  2. 2
    In C#, arrays are a collection of values that all share the same data type. You could have an array of type string that contains a list of your favorite songs, or an array of type int that stores a…
  3. 3
    We often want to know how many items an array contains. We can do this with the .Length property. int[] plantHeights = { 3, 4, 6 }; // arrayLength will be 3 int arrayLength = plantHeights.Length…
  4. 4
    Arrays are useful for storing values, but they’re not very useful if they simply stay there — we also need a way to access them. Arrays order items so that they’re in a specific sequence, w…
  5. 5
    Once we create an array, the size of that array is fixed. However, it’s possible to change the values it contains. For example, we can initialize an array that has a length of three without speci…
  6. 6
    In C#, there are several built-in methods we can use with arrays. The full list can be found in the [Microsoft documentation of the Array class, under methods](https://docs.microsoft.com/en-us/dotn…
  7. 7
    In addition to Sort(), IndexOf(), and Find(), there are several other built-in methods for arrays. You can find them (and you probably guessed it) in the [Microsoft documentation](https://docs.micr…
  8. 8
    Congratulations, we covered a lot in this lesson! We learned about: - Data structures and how we can use them to better organize our data - How to build, access, and edit values in arrays - How to…
  1. 1
    Imagine you’re building a video game and in this game, you want to add 15 aliens to the screen. How do we use code to tell a computer this: “Create a variable and call the method 15 times”? We co…
  2. 2
    Loops are used to repeat a set of instructions based on a set of conditions. If this makes you think of conditional statements, you’re not wrong! The while loop looks very similar to an if statem…
  3. 3
    Similar to the while loop, a do…while loop will continue running until a stopping condition is met. One key difference is that no matter what, a do…while loop will always run once. do { …
  4. 4
    What if we want our code to execute a specific number of times? We can use a for loop to do that. for (initialization; stopping condition; iteration statement) { statement; } The for loop te…
  5. 5
    There’s one more way to give looping instructions to a computer. We define a sequence of values and tell the computer to repeat the instructions for each item in the sequence. foreach (type elem…
  6. 6
    You may have noticed that there are lots of similarities between different types of loops, and you’re right! We just showed how we can use a foreach loop to iterate through an array. But we can a…
  7. 7
    There a few keywords we can use to add further control flow to our loops. Typically, they work with a series of nested loops, where one loop is written entirely within the body of another loop. T…
  8. 8
    Well done! In C#, loops are commonly used because they save time, reduce errors, and are easy to read. Being comfortable with each type of loop will make you a better programmer. In review: - A _lo…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo