[] Operator (C# Reference)
Square brackets ([]) are used for arrays, indexers, and attributes. They can also be used with pointers.
An array type is a type followed by []:
To access an element of an array, the index of the desired element is enclosed in brackets:
An exception is thrown if an array index is out of range.
The array indexing operator cannot be overloaded; however, types can define indexers, and properties that take one or more parameters. Indexer parameters are enclosed in square brackets, just like array indexes, but indexer parameters can be declared to be of any type, unlike array indexes, which must be integral.
For example, the .NET Framework defines a Hashtable type that associates keys and values of arbitrary type:
Square brackets are also used to specify Attributes (C# Programming Guide):
You can use square brackets to index off a pointer:
No bounds checking is performed.
For more information, see the following sections in the C# Language Specification:
-
1.6.7.5 Operators
-
7.2 Operators