What if you could find any item in a list instantly without counting every time?
Why Array indexing and access in C Sharp (C#)? - Purpose & Use Cases
Imagine you have a long list of your favorite songs written on paper. To find the 10th song, you have to count from the start every time. This takes time and can be tiring if the list is very long.
Manually counting each item to find what you want is slow and easy to mess up. You might lose your place or count wrong, making you pick the wrong song. Doing this again and again wastes your time and energy.
Array indexing lets you jump straight to the exact spot you want, like having a bookmark for each song number. You just say the number, and you get the song instantly, saving time and avoiding mistakes.
int[] numbers = {10, 20, 30, 40};
int thirdNumber;
for(int i = 0; i <= 2; i++) {
thirdNumber = numbers[i];
}
// manually countingint[] numbers = {10, 20, 30, 40};
int thirdNumber = numbers[2]; // direct access by indexWith array indexing, you can quickly and easily access any item in a list without counting or searching.
When using a photo album app, you can jump directly to the 5th photo by its position number instead of scrolling through all photos one by one.
Manual counting to find items is slow and error-prone.
Array indexing lets you access items instantly by their position.
This makes working with lists faster and less frustrating.