Single Dimensional Array in C#

In this article I will explain that how to create Single Dimensional Array.
  • 3391

Single dimensional array

The concept of single dimension array. In a single dimension array we need only one index to access the member of array. These types of arrays are used to store number of items of a predefined type. All items in a single dimension array are stored contiguously starting from 0 to the size of the array -1.

namespace demo_array

{

    class Program

    {   

        static void Main(string[] args)

        {

            // Create a single-dimensional array.

            int[] arr = new int[10];

            for (int x = 0; x < 10; x++)

            {

                Console.WriteLine("Enter array element : ", x);

                arr[x] = Int32.Parse(Console.ReadLine());

            }

            foreach (int i in arr)

            {

                Console.WriteLine(i);

            }

            Console.ReadLine();

        }

    }

} 

Output

single dimen_array.jpg

Ask Your Question 

Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.