29.3. Introducing pointers

There are three types in C#: value type, reference type, and the pointer type. Value types and reference types have been thoroughly covered in Chapter 9. Pointer types are only used in unsafe codes.

You will realize that pointer types are, in fact, very similar to reference types with two main differences. Like a pointer type, a reference type does not store the actual object or the values stored in the fields of an object, rather it stores an address to the actual object on the heap.

However, with a reference type you are unable to retrieve the actual address of the object it is referencing. C# shields you from all these low-level issues. You can retrieve the address of an object pointed to by a pointer type though. ...

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.