Fixing pointer variable in C#
Forums:
class Point {
public int x, y;
}
Point p = new Point {
x = 5,
y = 7
};
unsafe {
//to protect p.x from garbage collector
fixed (int* x = &p.x)
{
Console.WriteLine(*x);
}
}
- Log in to post comments