加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 如何知道事件的参数类型

发布时间:2020-12-16 00:08:27 所属栏目:百科 来源:网络整理
导读:我有一个事件,我将我的处理程序与它联系起来.当我编写处理程序方法时,如何知道函数采用哪些参数? 例: // Add an event handler to be called whenever there is new color frame data this.sensor.ColorFrameReady += this.SensorColorFrameReady; this.se
我有一个事件,我将我的处理程序与它联系起来.当我编写处理程序方法时,如何知道函数采用哪些参数?

例:

// Add an event handler to be called whenever there is new color frame data
            this.sensor.ColorFrameReady += this.SensorColorFrameReady;
            this.sensor.AllFramesReady += this.AllFramesReady;

    //handler
     private void AllFramesReady(object sender,AllFramesReadyEventArgs allFramesReadyEventArgs)
    {


        throw new NotImplementedException();
    }

我怎么知道我的函数的参数是对象发送者和所有帧准备args?

解决方法

您查找该事件的文档.它将指定委托定义该事件的内容.然后,您可以查找该委托的文档,以查看函数的签名必须与委托匹配.

或者你可以依靠Visual Studio来告诉你而不是查找它,这是大多数人所做的. (将鼠标悬停在事件上将告诉您委托必须是什么,或者在键盘中键入SomeEvent =会提示您创建一个具有正确签名的事件处理程序的新存根.)

请注意,参数的名称是无关紧要的(使用您想要的任何内容),只有类型很重要.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读