Exemplo n.º 1
0
 static void LSort(int[] arr, LambdaSort LOneSort = (x) => x > 0)
 {
 }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int[] arr = { 1, 2, 3, -10, -5, 6, -12, 144 };

            Console.WriteLine("Original array:");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");
            }
            Console.WriteLine();


            PrimitiveSort(arr);


            DelegateSort(arr, IntCompare);


            AnonymMethod AnonymSort = delegate(int[] AnonymArr)
            {
                int primitive_size = 0;

                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i] > 0)
                    {
                        primitive_size++;
                    }
                }

                int[] stack_arr = new int[primitive_size];
                int   j         = 0;

                for (int i = 0; i < arr.Length; i++)
                {
                    if (arr[i] > 0)
                    {
                        stack_arr[j] = arr[i];
                        j++;
                    }
                }

                Console.WriteLine(Environment.NewLine + "Anonym sorted array:");

                for (int i = 0; i < stack_arr.Length; i++)
                {
                    Console.Write(stack_arr[i] + " ");
                }

                Console.WriteLine();
            };

            AnonymSort(arr);


            LambdaSort LOneSort = (x) => x > 0;

            LSort(arr, LOneSort);

            Console.ReadKey();
        }