+1 vote
32 views
when i declare like this int a[]=new int[5]; visual studio shows error...when i declare like this int[] a=new int[5] it accepted?can anyone explain what is the need to declare like this?
asked Apr 28, 2016 in Computer Science - IT by gypsiii | 32 views

1 Answer

0 votes

The correct format to declare an array in c# is :

int [] a;

which denotes that int array namely 'a'

There are some syntax rules that every language follows , in c# too above things are considered for arrays

similarly you can declare a string array as :

string [] a;

Your second declaration was correct and it can accomodate upto 5 values (int [5])

answered Apr 28, 2016 by slow_learner
edited Apr 28, 2016 by slow_learner