Introduction:

 

In this article we will explain what is single dimensional array or How to declare one dimensional array or How to use single dimensional array in C# .net or how to access the value of array with example.

 

Description:

 

The single dimensional array or one dimensional array in C# is the simplest type of array that contains only one row for storing data. When we need to one or single row in case we can use of single dimension array. We can access the value of single dimensional array by using index number. The first or default item of array starts at the 0 index position. To declare single dimensional array in C#, you can write the following code.

 

string[] Language= new string[6];

 

Example:


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

 


Output:


What is single Dimension Array In C#.NET



I hope this article will help to you.

0 comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like