29.7. Using the * Indirection operator

Let's look at the third use of the * symbol in C#. You have seen * used:

  • as a binary multiplication operator (e.g. int x = 3*4;);

  • to denote a pointer referent type during declaration of a pointer type (e.g. long* pTemp; declares a pointer variable called pTemp of referent type long).

When applied on a single operand in unsafe codes, the * symbol becomes the indirection [14] operator.

[14] Indirection is also commonly called 'dereferencing'. These two terms are often used interchangeably in C/C++ literature.

The indirection operator is used to obtain the value of the variable to which the pointer points. It can only be applied to a pointer type with the exception of void*. Applying it to a non-pointer type ...

Get From Java to C#: A Developer's Guide 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.