Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# array declaration syntax vs c++ array declaration syntax

Tags:

c++

c#

.net

I am basically c++ guy,now learning c#. While array declaration I found that c# expects the square brackets after the type unlike c,c++. Is there any reason c# language specification is this way?

like image 672
ZoomIn Avatar asked May 07 '13 07:05

ZoomIn


1 Answers

The only good reason I can think of is to make a clear indication of the types of list1 and list2 in this construction:

In C#:

int[] list1, list2;

list2 is an array of ints.

In C++:

int list1[], list2;

list2 is an int.

Readability is key here.

like image 133
Emond Avatar answered Nov 03 '22 00:11

Emond