Arrays
In C#, arrays are a special entity. All arrays implicitly inherit from the System.Array type. The System.Array base class provides various methods used during the manipulation of arrays. Arrays are also index checked; that is, any attempt to access an invalid index, such as an index out of range, will generate an exception. In C and C++, simple arrays were not ranged checked and it was possible to overwrite the stack space or the heap; not so in C#.
The declaration of an array might seem slightly odd at first, but when you analyze the syntax, it actually makes much more sense than the C and C++ declaration for arrays.
The following syntax is used to allocate an array of Rank 1.
array-type[] var = new array-type[size]
Notice that the ...
Get C# and the .NET Framework: The C++ Perspective now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.