Sunday, July 12, 2009

How to declare and define an array in one statement in C#?

In the book I read, it says you can do it like this:





int[] intArray


intArray = int[5]





Isn't there a way to make this in one go, maybe like:





int[5] = intArray











Thanks!

How to declare and define an array in one statement in C#?
int[] intArray


intArray = int[5]





is incorrect. The book says





int[] intArray;


intArray = new int[5];





so to do it in one line:





int [] intArray = new int [5];
Reply:I am really sad to announce that arrays could be used the way he stated please take a look at


http://www.c-sharpcorner.com/U...


http://msdn.microsoft.com/libr... Report It



No comments:

Post a Comment