introductory-examples/structs/struct-demo-1.cs - Demonstrations of structs in C#. | Lecture 2 - slide 12 : 43 Program 1 |
using System; public struct Point { public double x, y; public Point(double x, double y){this.x = x; this.y = y;} public void Mirror(){x = -x; y = -y;} } // end Point public class StructDemo{ public static void Main(){ Point p1 = new Point(3.0, 4.0), p2; p2 = p1; p2.Mirror(); Console.WriteLine("Point is: ({0},{1})", p2.x, p2.y); } }