Use pointer indirection and . operator : Struct unsafe code : Struct C# Examples


C# Examples » Struct » Struct unsafe code »

 

Use pointer indirection and . operator









    
using  System;
using  System.Globalization;

struct  Point
{
    public  int  x;
    public  int  y;
    public  override  string  ToString()  
    {
        return  "("  +  x  +  ","  +  y  +  ")";
    }
}


public  class  MainClass{

    static  void  Main(string[]  args)
    {
        Console.WriteLine("Access  members  via.");
        unsafe
        {
            Point  point;
            Point*  p  =  &point;
            (*p).x  =  100;
            (*p).y  =  200;
            Console.WriteLine((*p).ToString());
        }
    }
}
    
   
  
   



Output

Access members via.
(100,200)


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Struct unsafe code