*myNumberPtr can be read as “the integer located at the memory value address held by myNumberPtr.”
Finally, pointers can also be declared for structs.
This can be done with the following code:
int* int1, int2;
Those developers would assume that int1 is a pointer to an integer, and int2 is just an integer. C# handles this statement differently, as the pointer declaration is on the type, not the variable. In this example, both int1 and int2 are pointers to integers.
Aside from placing code within an unsafe construct, you must also configure the compiler to allow unsafe code to be used. This can be done through the property pages for the project or by using the /unsafe switch flag with csc.exe.
The following code shows how to properly use the unsafe keyword in a couple of ways.