예제 #1
0
        static void ChangeProperties(ReferenceType instance)
        {
            instance.Number = 29;
            instance.String = "twentynine";

            Console.WriteLine("reference in method: {0} {1}", instance.Number, instance.String);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var referenceInstance = new ReferenceType();
            referenceInstance.Number = 1;
            referenceInstance.String = "one";

            ChangeProperties(referenceInstance);
            Console.WriteLine("reference: {0} {1}", referenceInstance.Number, referenceInstance.String);

            var valueInstance = new ValueType();
            valueInstance.Number = 1;
            valueInstance.String = "one";

            ChangeProperties(valueInstance);
            Console.WriteLine("value: {0} {1}", valueInstance.Number, valueInstance.String);
        }