Exemple #1
0
        static void Main(string[] args)
        {
            var pointStruct = new PointStruct();

            ProcessStruct(pointStruct);
            Console.WriteLine(pointStruct.X); // 0

            var pointClass = new PointClass();

            ProcessClass(pointClass);
            Console.WriteLine(pointClass.X); //10


            var str = new MyStruct();

            str.myObject = new MyClass();
            ProcessStruct2(str);
            Console.WriteLine(str.myObject.classField); //10

            Console.WriteLine("ref:");

            Point point = new Point();

            ProcessStruct3(ref point);
            Console.WriteLine(point.X); //10

            int n = 0;

            ProcessInt(ref n);
            Console.WriteLine(n); //10

            var array = new int[3];

            ProcessArray(ref array);
            Console.WriteLine(array.Length); //2
        }
Exemple #2
0
 static void ProcessStruct(PointStruct point)
 {
     point.X = 10;
 }