Beispiel #1
0
        public static void ChangeValues(int val1, MyNum val2)
        {
            Console.WriteLine("In ChangeValues() : before changing");
            Console.WriteLine("val1 \t val2");

            Console.WriteLine(val1 + "\t" + val2.GetValue());

            //changing the values,
            val1 = 777;
            val2.SetValue(888);

            Console.WriteLine("In ChangeValues() : after changing");
            Console.WriteLine("val1 \t val2");

            Console.WriteLine(val1 + "\t" + val2.GetValue());
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            int   val1 = 111;
            MyNum val2 = new MyNum(222);

            Console.WriteLine("Before calling change values method");
            Console.WriteLine("val1 \t val2");
            Console.WriteLine(val1 + "\t" + val2.GetValue());

            Console.WriteLine();

            ChangeValues(val1, val2);

            Console.WriteLine();
            Console.WriteLine("After calling change values method");
            Console.WriteLine("val1 \t val2");
            Console.WriteLine(val1 + "\t" + val2.GetValue());
        }
Beispiel #3
0
        public static void Main()
        {
            MyNum objA = new MyNum(5);
            MyNum objB = new MyNum(8);

            Console.WriteLine("Original Values:");
            Console.WriteLine("Object A is " + objA.GetValue());
            Console.WriteLine("Object B is " + objB.GetValue());

            objA.SetValue(666);
            Console.WriteLine("\nObject A is changed before Assignment");
            Console.WriteLine("Object A is " + objA.GetValue());
            Console.WriteLine("Object B is " + objB.GetValue());

            objA = objB;
            Console.WriteLine("\nAfter Assignment");
            Console.WriteLine("Object A is " + objA.GetValue());
            Console.WriteLine("Object B is " + objB.GetValue());

            objA.SetValue(444);
            Console.WriteLine("\nObject A is after Assignment");
            Console.WriteLine("Object A is " + objA.GetValue());
            Console.WriteLine("Object B is " + objB.GetValue());
        }