예제 #1
0
 static void increment(int i, string s, personStruct ps, personClass pc)
 {
     i++;
     s      += "s";
     ps.Age += 1;
     pc.Age += 1;
     return;
 }
예제 #2
0
        public void ValueRefTestMethod()
        {
            personStruct a = new personStruct {
                Name = "Raymond", Age = 18
            };
            personClass b = new personClass {
                Name = "Raymond", Age = 18
            };

            int    i = 18;
            string s = string.Empty;

            increment(i, s, a, b);
            Trace.WriteLine(string.Format("i={0}, s={1}, a={2}, b={3}", i, s, a.Age, b.Age));

            increment(i, s, a, b);
            Trace.WriteLine(string.Format("i={0}, s={1}, a={2}, b={3}", i, s, a.Age, b.Age));

            // i = 18, s =, a = 18, b = 19
            // i = 18, s =, a = 18, b = 20
        }