Key Concepts

Review core concepts you need to learn to master this subject

C# Arrays

// `numbers` array that stores integers int[] numbers = { 3, 14, 59 }; // 'characters' array that stores strings string[] characters = new string[] { "Huey", "Dewey", "Louie" };

In C#, an array is a structure representing a fixed length ordered collection of values or objects with the same type.

Arrays make it easier to organize and operate on large amounts of data. For example, rather than creating 100 integer variables, you can just create one array that stores all those integers!

Lesson 1 of 2
  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](…
  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…

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