O'Reilly logo

Microsoft® .NET Compact Framework (Core Reference) by Mark Sutton, Rory MacLoed, Robert Burbidge, Stephen Wheelwright, Andy Wigley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Simple Arrays

The System.Array class represents a simple collection of objects. In fact, you never instantiate this class directly. Instead, you use the built-in language features. The following C# example illustrates the use of the Array class:

int[] myIntArray = new int[10];

You code the same thing in Visual Basic .NET in one of two ways:

Dim myIntArray() As Integer = New Integer(9) {}
Dim myIntArray(9) As Integer    ’implies New Integer(9)

In C#, you must use the new language keyword to initialize an array. If you leave it out, the array variable is uninitialized and points to nothing.

You must include the initialization braces {} when declaring an array in Visual Basic using the New keyword, even if you do not supply any initialization values; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required