zoukankan      html  css  js  c++  java
  • 委托所想

    delegate是一个像class的关键字,delegate void Click_HandleEvent(object sender,string args)和class Person一样。都是定义一个类型。

    当使用Click_HandleEvent handle是引用了一个类型的变量。当Person p也是引用了一个变量。

    使用Fun和Action的好处是不用定义Delegate void Click_HandleEvent定义一个类型了。因为Fun和Action充当了声明一个事件。

    委托作为参数的好处是,让具体的委托延迟到了调用的地方。

    GetConsumeHistoryList(Action<ConsumeHistory, string> callback, string mStartTime, string mEndTime, int mStartIndex, int mCount)

    {

           if (res.serverResultCode == ResultCode.STATUS_OK && null != res.readerStruct)
                        {
                            ConsumeHistory mConsumeHistory = res.readerStruct as ConsumeHistory;
                            if (null != mConsumeHistory)
                            {
                                callback(mConsumeHistory, res.serverResultCode);
                            }
                        }

    }

    当某个地方调用GetConsumeHistoryList时,可以具体的指定callback的函数实现过程。

  • 相关阅读:
    Ceph
    linux五天光速入门
    shell编程
    Docker&K8S&持续集成与容器管理--系列教程
    openstack系列
    爬虫快速入门
    python奇闻杂技
    机器学习
    数据分析
    量化分析
  • 原文地址:https://www.cnblogs.com/lzhp/p/3496312.html
Copyright © 2011-2022 走看看