01-08-2012, 01:44 PM
Programming in C# Arrays and Indexers
Programming in C.ppt (Size: 173.5 KB / Downloads: 50)
Array Declarations
An array is an object (not just a stream of objects). See System.Array.
Bounds checking is performed for all access attempts.
Declaration similar to Java, but more strict.
Type definition: a is a “1D array of int’s”
Instance specifics: a is equal to a 1D array of int’s of size 10.
C# Arrays
Multi-dimensional arrays are jagged arrays with a user-enforced constraint in C.
Really just 1D arrays, but each element can contain a 1D array (recursion).
C# provides true multi-dimensional arrays
Elements are stored sequentially
CLR (JIT compiler) computes the offset code
Indexers
Allow bracket notation on any object
public string this[int a, double b]
{ … }
Related to C++ operator[ ] overloading
Special property