static void Main() { MyClass t1 = new ca2.MyClass(); MyClass t2 = new MyClass(88); MyClass t3 = new MyClass(17.23); MyClass t4 = new MyClass(2, 4); Console.WriteLine("t1.x: " + t1.x); Console.WriteLine("t2.х: " + t2.x); Console.WriteLine("t3.x: " + t3.x); Console.WriteLine("t4.x: " + t4.x); }
static void Main() { MyClass ob1 = new ca2.MyClass(4, 5); MyClass ob2 = new MyClass(6, 7); Console.Write("ob1: "); ob1.Show(); Console.Write("ob2: "); ob2.Show(); if (ob1.SameAs(ob2)) { Console.WriteLine("ob1 и ob2 имеют одинаковые значения."); } else { Console.WriteLine("ob1 и ob2 имеют разные значения."); } Console.WriteLine(); // А теперь сделать объект ob1 копией объекта ob2. ob1.Copy(ob2); Console.Write("ob1 после копирования: "); ob1.Show(); if (ob1.SameAs(ob2)) { Console.WriteLine("ob1 и ob2 имеют одинаковые значения."); } else { Console.WriteLine("ob1 и ob2 имеют разные значения."); } }