Copy a struct. : Struct copy : Struct C# Examples


C# Examples » Struct » Struct copy »

 

Copy a struct.









    
using  System;  
  
struct  MyStruct  {  
    public  int  x;  
}  
  
class  MainClass  {  
    public  static  void  Main()  {  
        MyStruct  a;  
        MyStruct  b;  
  
        a.x  =  10;  
        b.x  =  20;  
  
        Console.WriteLine("a.x  {0},  b.x  {1}",  a.x,  b.x);  
  
        a  =  b;  
        b.x  =  30;  
  
        Console.WriteLine("a.x  {0},  b.x  {1}",  a.x,  b.x);  
    }  
}
    
   
  
   



Output

a.x 10, b.x 20
a.x 20, b.x 30


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Struct
» Struct copy