Array Indexing and Access in C#
📖 Scenario: You are working on a simple program that stores the names of fruits in an array. You want to access specific fruits by their position in the array.
🎯 Goal: Build a C# program that creates an array of fruits, sets an index variable, accesses the fruit at that index, and prints it.
📋 What You'll Learn
Create an array called
fruits with these exact values: "Apple", "Banana", "Cherry", "Date", "Elderberry"Create an integer variable called
index and set it to 2Access the fruit at position
index in the fruits array and store it in a variable called selectedFruitPrint the value of
selectedFruit exactly💡 Why This Matters
🌍 Real World
Arrays are used to store lists of items like names, prices, or dates. Accessing items by index helps you get or change specific data quickly.
💼 Career
Knowing how to work with arrays and access their elements is a basic skill for many programming jobs, including software development and data processing.
Progress0 / 4 steps