예제 #1
0
        static void Main(string[] args)
        {
            OutVariableDeclarations();
            TupleDeclarations();
            TupleMethod();

            // <SnippetDeconstructPoint>
            var p = new Point(3.14, 2.71);

            (double X, double Y) = p;
            // </SnippetDeconstructPoint>
            Console.WriteLine(X);
            Console.WriteLine(Y);

            Patterns.IsPatternTestOne();

            Patterns.SwitchPatternSimple();
            Patterns.SwitchPatternFull();

            MatrixSearch.EverythingByValue();

            int[,] matrix = new int[10, 10];
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    matrix[x, y] = x * 10 + y;
                }
            }

            // <SnippetAssignRefReturn>
            ref var item = ref MatrixSearch.Find(matrix, (val) => val == 42);
예제 #2
0
        static void Main(string[] args)
        {
            var util = new FactorialExample();

            util.LocalFunctionFactorial(100);
            return;

            OutVariableDeclarations();
            TupleDeclarations();
            TupleMethod();

            #region 12_DeconstructPoint
            var p = new Point(3.14, 2.71);
            (double X, double Y) = p;
            #endregion
            Console.WriteLine(X);
            Console.WriteLine(Y);

            #region 13_DeconstructNames
            (double horizontalDistance, double verticalDistance) = p;
            #endregion
            Console.WriteLine(horizontalDistance);
            Console.WriteLine(verticalDistance);

            int[,] matrix = new int[10, 10];
            for (int x = 0; x < 10; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    matrix[x, y] = x * 10 + y;
                }
            }

            #region 21_UpdateItemFromIndices
            var indices = MatrixSearch.Find(matrix, (val) => val == 42);
            Console.WriteLine(indices);
            matrix[indices.i, indices.j] = 24;
            #endregion

            matrix[indices.i, indices.j] = 42;

            #region 23_AssignRefReturnToValue
            var valItem = MatrixSearch.Find3(matrix, (val) => val == 42);
            Console.WriteLine(valItem);
            valItem = 24;
            Console.WriteLine(matrix[4, 2]);
            #endregion

            #region 24_AssignRefReturn
            ref var item = ref MatrixSearch.Find3(matrix, (val) => val == 42);