Introduction to Array in C#

In this article I will explain Introduction in Array.
  • 3861

Introduction

In C#, an array is a fixed collection of same-type data that are stored contiguously and that are accessible by an index. Arrays can be declared as fixed length or dynamic. Array index starts at zero. That means the first item of an array starts at the 0th position. The position of the last item on an array will total number of items - 1. So if an array has 5 items, the last 5th item is at 4th position.

Example of array

namespace demo_array

{

    class Program

    {

        static void Main(string[] args)

        {

           int [] intno = new int[5];

           intno[0] = 10;

           intno[1] = 20;

           intno[2] = 30;

           intno[3] = 40;

           intno[4] = 50;

           foreach (int intval in intno)

            {

                Console.WriteLine(intval);               

            }

            Console.ReadKey();

        }

    }

}

Output

array_introduction.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.