Accessing Structure Members with a Pointer : Unsafe : Unsafe C# Examples


C# Examples » Unsafe » Unsafe »

 

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);
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Unsafe
» Unsafe