コード例 #1
0
        private static void TestDelegates()
        {
            Del handler = DelegateMethod;

            Console.WriteLine($"The type of handler is {handler.GetType()}");

            handler("Text to pass to DelegateMethod through the delegate Del");

            MethodForSumOfNumbersWithCallback(1, 2, handler);

            var collection = new List <int> {
                1, 2, 3, 4, 5
            };

            // function (Linq) as parameter for the function Where of the Assembly System => so it is Delegate
            var evenFromCollection = collection.Where(x => x % 2 == 0).Select(x => x).ToList();

            Console.WriteLine(string.Join(", ", evenFromCollection));
            Console.Read();
        }
コード例 #2
0
 public void SupportedAttributes(Type supportedType)
 {
     Assert.That(supportedType.IsAssignableFrom(_tag.GetType()));
 }