在c#中明确定义事件 [英] Explicitly Defining an Event in c#

查看:92
本文介绍了在c#中明确定义事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,

我需要了解事件

在我的API中,事件就像IDocumentsEvents一样,Save(),Modified(某些参数)在那里当文档被修改时,事件和描述就像火一样。

现在我仍然处理了当我们点击TAB两次时会产生的事件,它会自动生成

但是这里显示它作为方法,没有事件在+ =正常事件上创建

有人能告诉我此类事件的使用方法如何调用以及有关此类事件的信息



提前谢谢

Hello Guys,
I need to know about Events
In my API the events are like IDocumentsEvents in that Save(),Modified(some parameters) are there as Events and descriptions as fires when document si modified.
Still now i worked on events that raised when we tap the TAB twice it will auto generated
but here it is showing it as methods and no event is creating on += like normal events
Can someone tell me the usage of this type of events how to call and information about this type of events

Thanks in advance

推荐答案

创建自己的事件并提高它们并不困难:我经常创建一个Visual Studio片段给我一个捷径:一个简单的代码片段添加事件 [ ^ ]

显示创建事件所需的代码,然后你需要做的就是调用它OnMyEventName方法,传递它需要传递的事件args。
Creating your own events and raising them isn't difficult: I do it so often I created a Visual Studio snippet to give me a short cut: A Simple Code Snippet to Add an Event[^]
That shows the code you need to create the event, then all you have to do to raise it is to call the OnMyEventName method, passing it the event args you need to pass on up.


这篇关于在c#中明确定义事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆