int arrays

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I found this line in a Microsoft help, but it doesn't compile
int[] arr = new int[5];
How can I create an int array?
I tried
Int[] arr = new Int[5];
but it created other problems.
 
int[] arr = new int[5]; is the correct syntax for creating a new array of 5
elements that is referenced by the variable arr.

Capitalizing the i in int would not work as C# is case sensitive when it
comes to variable types.

What is the error(s) you are getting when you attempt to compile.

Brendan
 
I found this line in a Microsoft help, but it doesn't compile
int[] arr = new int[5];

Correct syntax and should work.
How can I create an int array?
I tried
Int[] arr = new Int[5];
Will not compile as Int is not a valid data-type.

You can alternatively use System.Int32 in place of int.
As both are internally same when converted to MSIL. int is basically a
keyword of C# which gets converted to System.Int32 on IL generation.
 
I think was mixing up "[" with"(".

Brendan Grant said:
int[] arr = new int[5]; is the correct syntax for creating a new array of 5
elements that is referenced by the variable arr.

Capitalizing the i in int would not work as C# is case sensitive when it
comes to variable types.

What is the error(s) you are getting when you attempt to compile.

Brendan

Arne said:
I found this line in a Microsoft help, but it doesn't compile
int[] arr = new int[5];
How can I create an int array?
I tried
Int[] arr = new Int[5];
but it created other problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top