One Dimensional Array In C#

In this article i am explaining about single dimension array in C#. The single dimensional array or one dimensional array in C# is the easy type of array that contains only one row for storing data. It has single set of square bracket (“[]”). Create single dimensional array in C#, you can write the following code.

string[] Books = new string[5];

The array books is a one dimensional array that contains only 5 elements in a single row.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace One_Dimensional_Array_Example
    class Program
        static void Main(string[] args)
            //Declaring single dimensional array
            string[] Books = new string[5];
            Books[0] = "C#";
            Books[1] = "Java";
            Books[2] = "VB.NET";
            Books[3] = "C++";
            Books[4] = "C"; 
            Console.WriteLine("All the element of Books array is:\n\n");
            int i = 0;
            //Formatting Output
            for (i = 0; i < 5; i++)
                Console.Write("{0}\t", Books[i]);

Leave a Reply

Your email address will not be published. Required fields are marked *