What is an array?

An array is a collection of the same data types. For example, an array could contain all strings. Arrays can be looped over to display their items, sorted, and many other operations.

Use a set of square brackets, [], after the data type to declare an array. Arrays are usually named with a plural word. In the example below, an array of strings is named foods.

Example: Declare an array

string[] foods;

Get hands-on with 1200+ tech skills courses.