static void Main(string[] args) { Simple s1 = new Simple(); Simple s2 = new Simple(10, 10); Console.WriteLine("{0}, {1}", s1.X, s1.Y); // Call implicit constructor Console.WriteLine("{0}, {1}", s2.X, s2.Y); // Call explicit constructor }
static void Main(string[] args) { CSimple cs1 = new CSimple(), cs2 = null; // Class instances Simple ss1 = new Simple(), ss2 = new Simple(); // Struct instances cs1.X = ss1.X = 5; // Assign 5 to ss1.X and cs1.X. cs1.Y = ss1.Y = 10; // Assign 10 to ss1.Y and cs1.Y. cs2 = cs1; // Assign class instance. copy the references ss2 = ss1; // Assign struct instance.copy the values }
static void Main(string[] args) { CSimple cs1 = new CSimple(), cs2 = null; Simple ss1 = new Simple(), ss2 = new Simple(); cs1.X = ss1.X = 5; cs1.Y = ss1.Y = 10; cs2 = cs1; ss2 = ss1; }