static void Main(string[] args) { MyClass ob1 = new MyClass(4, 5); MyClass ob2 = new MyClass(6, 7); Console.WriteLine("ob1 :"); ob1.Show(); Console.WriteLine(); Console.WriteLine("ob2 :"); ob2.Show(); Console.WriteLine(); if (ob1.SameAs(ob2)) { Console.WriteLine("ob1 and ob2 have the same values."); } else { Console.WriteLine("ob1 and ob2 have different values."); } Console.WriteLine(); ob1.Copy(ob2); Console.Write("ob1 after copy: "); ob1.Show(); if (ob1.SameAs(ob2)) { Console.WriteLine("ob1 and ob2 have the same values."); } else { Console.WriteLine("ob1 and ob2 have different values."); } Console.WriteLine(); Console.WriteLine(); int a = 15; int b = 20; Console.WriteLine("a and b befor call: " + a + " " + b); Test ob = new Test(); ob.NoChanges(a, b); Console.WriteLine("a and b after call: " + a + " " + b); Console.WriteLine(); Console.WriteLine(); Test_2 ob_2 = new Test_2(15, 10); Console.WriteLine("ob.a and ob.b before call: " + ob_2.a + " " + ob_2.b); ob_2.Change(ob_2); Console.WriteLine("ob.a and ob.b after call: " + ob_2.a + " " + ob_2.b); }
public void Change(Test_2 ob) { ob.a = ob.a + ob.b; ob.b = -ob.b; }