Declaration Of Array In C# – Programming, Pseudocode Example, C# Programming Example
Arrays C Programming C# Console

Declaration Of Array In C#

In this ttutorial, We’ll learn : What is array?, How to declare array?,How to use array in C#.

Sometimes, you need to declare multiple variable of same data type. It is complex and time consuming process. Just for an example, you have to declare 100 integer type of variable then what would you do? Will you declare variable as follow:

It is not a suitable way to declare multiple variable of same data type. To overcome this situation, array came alive. An array is a collection of same data type. If you have to declare 100 variable of same data type in C#, then you can declare and initialize an array as follow.

To understand concept of array, consider the following example. What happens in memory when we declare an integer type array?

It stores the values in the index position of the array starting with 0.

num[0] = 6;
num[1] = 23;
num[2] = 12;
num[3] = 9;
num[4] = 14;
num[5] = 52;

Now, you can access the value of array by index position. Such as if you have to access 2nd index of value, then you can write as follow:

PROGRAMMING EXAMPLE OF ARRAY

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: