C#中的事件处理 [英] Event Handling in C#

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

问题描述

大家好,


我想在类的静态变量上创建一个事件。

目的是在静态变量时通知类变量值已更改,因此可以进行一些处理。


请帮我这样做。

谢谢&问候

Nishant Guarav

Hi All,

I want to create a event on a static variable of the class.
The intention is to notify the class whenever the static variable value is changed, so that it can do some processings.

Please help me do this.
Thanks & Regards
Nishant Guarav

推荐答案

查看属性,您可以从set block构建事件提升者。例如:

Have a look at properties, you can build the event raiser from the set block. eg:

展开 | 选择 | Wrap | < span class =codeLinkonclick =LineNumbers(this);>行号


感谢AmzBee的回复,我做了同样的事情但是没能得到当某个其他类中的静态值发生变化时,事件处理程序会对此做出响应。

如果你能用一个例子来展示它是如何做到的,那将是很有帮助的。


谢谢&问候

Nishant Gaurav
thanks AmzBee for the response, i did the same thing but was not able to get the event handler respond to that, when the static value was changed in some other class.
It will be of great help if u can show it with a example how this can be done.

Thanks & Regards
Nishant Gaurav


嗨!


请提供你实际编写的代码,所以我'能够找出你做错了什么。


当房产的价值发生变化时,你想通知谁?静态类或此类的任何实例?
Hi!

Please provide the code you''ve actually written, so I''d be able to find out what you''ve done wrong.

Who do you want to notify when the property''s value is changed? The static class or any instance of this class?


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

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