Accessing Structure Members with a Pointer
using System;
public struct Point2D {
public int X;
public int Y;
}
public class MyClass {
public unsafe static void Main() {
Point2D MyPoint;
Point2D * PointerToMyPoint;
MyPoint = new Point2D();
PointerToMyPoint = &MyPoint;
PointerToMyPoint->X = 100;
PointerToMyPoint->Y = 200;
Console.WriteLine("({0}, {1})", PointerToMyPoint->X, PointerToMyPoint->Y);
}
}
Related examples in the same category