Esempio n. 1
0
        private static void UsingDelegates()
        {
            string s1          = "Hello";
            string s2          = "World";
            var    comparators = new StringComparators();

            ComparisonTest test = new ComparisonTest(comparators.CompareContent);

            Console.WriteLine("CompareContent returned: {0}", test(s1, s2));

            test = new ComparisonTest(StringComparators.CompareLength);
            Console.WriteLine("CompareLength returned: {0}", test(s1, s2));

            ComparisonTest test2 = comparators.CompareContent;
        }
Esempio n. 2
0
        private static void UsingFuncAndAction()
        {
            string s1          = "Hello";
            string s2          = "World";
            var    comparators = new StringComparators();

            Func <string, string, bool> test = comparators.CompareContent;

            Console.WriteLine("CompareContent returned: {0}", test(s1, s2));

            test = StringComparators.CompareLength;
            Console.WriteLine("CompareLength returned: {0}", test(s1, s2));

            test = (input1, input2) => (input1.Length % 2) == (input1.Length % 2);
            Console.WriteLine("Modulo compare with lambda returned: {0}", test(s1, s2));

            Action <string, string> actionExample = (input1, input2) => Console.WriteLine("input1: {0} input2: {1}", input1, input2);

            actionExample(s1, s2);
        }
Esempio n. 3
0
        private static void UsingFuncAndAction()
        {
            string s1 = "Hello";
            string s2 = "World";
            var comperators = new StringComparators();

            Func<string, string, bool> test = comperators.CompareContent;
            Console.WriteLine("CompareContent returned: {0}", test(s1, s2));

            test = StringComparators.CompareLength;
            Console.WriteLine("CompareLength returned: {0}", test(s1, s2));

            test = (input1, input2) => (input1.Length % 2) == (input1.Length % 2);
            Console.WriteLine("Modulo compare with lambda returned: {0}", test(s1, s2));

            Action<string, string> actionExample = (input1, input2) => Console.WriteLine("input1: {0} input2: {1}", input1, input2);
            actionExample(s1, s2);
        }
Esempio n. 4
0
        private static void UsingDelegates()
        {
            string s1 = "Hello";
            string s2 = "World";
            var comperators = new StringComparators();

            ComparisonTest test = new ComparisonTest(comperators.CompareContent);
            Console.WriteLine("CompareContent returned: {0}", test(s1, s2));

            test = new ComparisonTest(StringComparators.CompareLength);
            Console.WriteLine("CompareLength returned: {0}", test(s1, s2));

            ComparisonTest test2 = comperators.CompareContent;
        }