• 多个委托方法的顺序执行


    using System;
    namespace 委托和事件
    {
        internal class Program
        {
            private static void Main(string[] args)
            {
                Action action = One;
                action += Two;
                action += Three;
                Delegate[] delegates = action.GetInvocationList(); //返回委托挂接的方法,通过他可以控制委托方法执行顺序
                foreach (Action delegateAction in delegates)
                {
                    try
                    {
                        delegateAction();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                Console.Read();
            }
            private static void One()
            {
                Console.WriteLine("调用:方法一");
                throw new Exception("Err in one");
            }
            private static void Two()
            {
                Console.WriteLine("调用:方法二");
            }
            private static void Three()
            {
                Console.WriteLine("调用:方法三");
            }
        }
    }
  • 相关阅读:
    ant design 中的 Select 组件常规写法
    React.createRef()
    taro 打包微信小程序运行失败(二)
    taro 打包微信小程序运行失败(一)
    获取图片的metaData
    为什么有时候NSData转换成NSString的时候返回nil
    动态切换tableView中的cell的种类
    UIImagePickerController按钮的中文问题
    可以触发点击事件并变色的UILabel
    模拟系统照相机图片裁剪的功能
  • 原文地址:https://www.cnblogs.com/zhangqs008/p/3061610.html
Copyright © 2020-2023  润新知