In C # the keyword unsafe is used to use the pointers.
_ Must be compiled with the / unsafe option. To set this option in Visual Studio:
- Open the Project Properties page.
- Click on the Generate property page.
- Check the Allow non-secure code check box.
_ Methods, types and blocks of code can be defined as unsafe.
-Types of pointers:
type * identifier;
void * identifier; // allowed but not recommended
A pointer can be type sbyte, byte, short, ushort, int, uint, long, ulong, char, float, double, decimal or bool, any type of enum, pointer or struct that only contains fields of unmanaged types.
Declare several pointers in the same declaration:
int * p1, p2, p3; // Okay
int * p1, * p2, * p3; // Invalid in C #
int * p (p is a pointer to an integer)
int ** p (p is a pointer to a pointer or an integer)
int *  p (p is a one-dimensional array of integer pointers)
char * p (p is a pointer to a char value)
void * p (p is a pointer to an unknown type)