Exemple #1
0
        static void Main(string[] args)
        {
            //--------------------- Memory fun --------------------------
            PairOfInts z  = new PairOfInts(1, 2);
            Program    p1 = new Program(z, "first", 1);
            Program    p2 = new Program(z, "second", 2);
            Program    p3 = null;
            Program    p4 = p1.Clone() as Program;

            Console.WriteLine(p1.name + " : " + p1.pair.a + " : " + p1.pair.b);
            Console.WriteLine(p4.name + " : " + p4.pair.a + " : " + p4.pair.b);

            p1.name   = "hello";
            p1.pair.a = 11;
            p4.pair.b = 12;

            Console.WriteLine(p1.name + " : " + p1.pair.a + " : " + p1.pair.b);
            Console.WriteLine(p4.name + " : " + p4.pair.a + " : " + p4.pair.b);

            //--------------------- Mutable array --------------------------
            //int[] a = { 1, 2, 3, 4 };
            //ChangeArr(a);
            //foreach (var item in a)
            //{
            //    Console.WriteLine(item);
            //}

            Console.ReadLine();
        }
Exemple #2
0
 public Program(PairOfInts p, string s, int x)
 {
     pair    = p;
     name    = s;
     pair.a += x;
 }