Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Indexing | Arrays
C# Basics

IndexingIndexing

Every element of an array has an index which is simply its position in the array. The first element has the index 0, the second element has the index 1, and so on. Since indices start from 0, the last element's index is 1 less than the size of the array (size - 1).

The following illustration is a slightly modified version of the one from the last chapter however this time the elements have their corresponding indices written beneath them:

We can access an element of an array using the following syntax:

cs

main.cs

For-example:

cs

main.cs

In the above code, we access the 10th element of the array and it outputs 0. This is because when we create a new empty array it is automatically filled with relevant zero values according to its data type.

Each element of an array is essentially a variable. We can access and modify an element of an array using the following syntax:

cs

main.cs

For-example:

cs

main.cs

What will be the output of the following code?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 5. Розділ 3
course content

Зміст курсу

C# Basics

IndexingIndexing

Every element of an array has an index which is simply its position in the array. The first element has the index 0, the second element has the index 1, and so on. Since indices start from 0, the last element's index is 1 less than the size of the array (size - 1).

The following illustration is a slightly modified version of the one from the last chapter however this time the elements have their corresponding indices written beneath them:

We can access an element of an array using the following syntax:

cs

main.cs

For-example:

cs

main.cs

In the above code, we access the 10th element of the array and it outputs 0. This is because when we create a new empty array it is automatically filled with relevant zero values according to its data type.

Each element of an array is essentially a variable. We can access and modify an element of an array using the following syntax:

cs

main.cs

For-example:

cs

main.cs

What will be the output of the following code?

Виберіть правильну відповідь

Все було зрозуміло?

Секція 5. Розділ 3
some-alt