Store and iterate through sequences of data using Arrays and the foreach statement in C#

Beginner
Developer
Higher Education Educator
K-12 Educator
Student
.NET
Visual Studio Code

Work with sequences of related data in data structures known as arrays. Then, learn to iterate through each item in the sequence.

Learning objectives

In this module, you will:

  • Create and initialize a new array.
  • Set and get values in arrays.
  • Iterate through each element of an array using the foreach statement.

Prerequisites

  • Experience with declaring and initializing variables and basic data types like string.
  • Experience with printing to output using Console.WriteLine().
  • Experience with string interpolation to combine literal strings with variable data.
  • Experience researching how to use methods from the .NET Class Library.