Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'        Annotated program -- Keyboard shortcut: 't'    introductory-examples/structs/struct-demo.cs - An extended demonstration of structs in C#.Lecture 2 - slide 12 : 43
Program 3

/* Right, Wrong */   

using System;

public struct Point1 {  
  public double x, y;
}   

public struct Point2 {  
  public double x, y;   
  public Point2(double x, double y){this.x = x; this.y = y;}  
  public void Mirror(){x = -x; y = -y;}                       
}   

public class StructDemo{

 public static void Main(){

   /*   
   Point1 p1;  
   Console.WriteLine(p1.x, p1.y);   
   */
   
   Point1 p2;  
   p2.x = 1.0; p2.y = 2.0;    
   Console.WriteLine("Point is: ({0},{1})", p2.x, p2.y);   

   Point1 p3;
   p3 = p2;                    
   Console.WriteLine("Point is: ({0},{1})", p3.x, p3.y);   
   
   Point2 p4 = new Point2(3.0, 4.0);   
                                       

   p4.Mirror();                        
   Console.WriteLine("Point is: ({0},{1})", p4.x, p4.y);   
 }

}