Definition - What does Indirection operator mean?
The indirection operator can be used in a pointer to a pointer to an integer, a single-dimensional array of pointers to integers, a pointer to a char, and a pointer to an unknown type.
The indirection operator is also known as the dereference operator.
Techopedia explains Indirection operator
C# allows using pointers only in an unsafe region, which implies that the safety of the code within that region is not verified by the common language runtime (CLR). In the unsafe region, the indirection operator is allowed to read and write to a pointer. The following C# statements illustrate the usage of the indirection operator:
- int a = 1, b; // line 1
- int *pInt = &a; // line 2
- b = *pInt; // line 3
The indirection operator should be used to dereference a valid pointer with an address aligned to the type it points to, so as to avoid undefined behavior at runtime. It should not be applied to a void pointer or to an expression that is not of a pointer type, to avoid compiler errors. However, after casting a void pointer to the right pointer type, the indirection operator can be used.
When declaring multiple pointers in a single statement, the indirection operator should be written only once with the underlying type and not repeated for each pointer name. The indirection operator is distributive in C#, unlike C and C++. When the indirection operator is applied to a null pointer, it results in an implementation-defined behavior. Since this operator is used in an unsafe context, the keyword unsafe should be used before it along with the /unsafe option during compilation.
Join thousands of others with our weekly newsletter
The 4th Era of IT Infrastructure: Superconverged Systems:
Approaches and Benefits of Network Virtualization:
Free E-Book: Public Cloud Guide:
Free Tool: Virtual Health Monitor:
Free 30 Day Trial – Turbonomic: