Introduction:


In this article we will explain what is array in c# or why use array in c# or what are the different


type of array in c#.

 

Description:


Array is a collection/group of variables of same data type. When you need to declare 100 integer or string variables, then you can declare an integer or string array of 100 size. We can access array value by using index position of array. The index position of array are set to zero.

 

In C#, support two types of array: Single Dimensional Array and Multi Dimensional Array. You can use both type of array easily and can access its value by using loop constructs or index position.

  • Integer Array

Declaring and Initializing an Integer Array

int[] array = new int[4];
 
array[0]= 20;
array[1]= 30;
array[2]= 40;
array[3]= 50;
  • String Array

Declaring and Initializing an String Array

string[] array = new string[5];
 
 array[0] = "B";
 array[1] ="A";
 array[2] = "C";
 array[3] = "D";

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