Arrays in .NET are objects in their own right, objects that are responsible for holding a collection of other objects. This means that they have methods you can call and properties you can interact with, and as you would expect, they are mapped onto the native arrays supported by the .NET languages. Note

For VB programmers, arrays are indexed from zero in .NET, which means you may have problems if you have relied in the past on using Option Base to set the array index base to one. See the Immediate Solutions section for details on how to deal with this situation.

The System.Array class provides methods for creating, searching, manipulating, and sorting arrays, and it serves as the base for all arrays in the .NET world. It supports multidimensional arrays, although the syntax for using them is not very tidy.

In practice, you'll tend to use the native array types provided by the language you are coding in, but you can use the System.Array class if you want to. There are some members of System.Array that are very useful, and that aren't provided by most language array implementations.

Note that arrays are not thread safe. The array class does contain two properties relating to thread safety, but they don't do anything. The first one, IsSynchronized(), returns a Boolean value indicating whether access to the array is synchronized or not. By default, this simply returns False, although the method could be overridden by a derived class. The second property, SyncRoot, returns a reference to an object that can be used to synchronize access to an array.

If you want to implement thread-safe arrays, you can derive your own class from System.Array and override these properties.

0 0

Post a comment