Pointers

In this section, we focus on pointers and you learn to use them safely. Many of you who have programmed in C extensively won't find too much new information.

Internally, a pointer is nothing else than a guide to an object. In other words, a pointer contains the address of an object in memory. Pointers are low-level stuff, so you'll have to deal with addresses. That's the reason why pointers are dangerous: Data can easily be put into the wrong part of the memory.

Fundamental Operations and Basics

Now it's time to look at an example so that you can see how to work with pointers and addresses:

 using System; public class Demo { unsafe static void Main() { int i = 10; int *j; j = &i; i = 20; Console.WriteLine("i: {0} - j: {1}", i, *j); } ...

Get Mono Kick Start 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.