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的函数实现过程。

  • 相关阅读:
    【转】排序总结(总结的非常好)
    [转]C#中使用指针实现高效比较字符串的小技巧
    高斯消元法
    排序算法性能和使用场景总结
    斐波那契数列Log(n)算法
    C#部分方法定义
    杂项记录
    C#指针复习示例zz
    【转】斐波那契数列算法分析
    【转】矩阵乘法
  • 原文地址:https://www.cnblogs.com/lzhp/p/3496312.html
Copyright © 2011-2022 走看看