9.2. Reference types

Reference types in C# are identical to Java reference types – they refer to objects on the heap. You can skip to the next section if you are already clear about Java reference types – I have included the following paragraphs just to make the text more complete.

Like Java, and unlike C/C++, C# reference types are type-safe, meaning that it is impossible for a reference type variable to refer to some unallocated or random memory space which you can corrupt. Such type-safety means that a C# application cannot corrupt memory which has not been allocated for that application running on the Windows operating system (which supports multi-programming). The only way a C# program can access memory locations directly is via pointer ...

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.