ButtonClick事件访问没有Class实例在另一个Class中 [英] ButtonClick event access without Class instance in another Class

查看:70
本文介绍了ButtonClick事件访问没有Class实例在另一个Class中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我有一个带有ButtonClick事件的A类,我想在另一个类中访问这个Clickevent,是否可以不提供A类实例?



请让我知道谢谢

解决方案

是不可能的,因为事件是一个属于的方法A类,所以为了访问任何类的非静态成员,你必须拥有该类的对象,并且该成员必须是公共的(如果你的类不是继承A类,否则也可以被保护或者是内部的)!

Hello,

I have Class A with ButtonClick Event, i want to access this Clickevent in another class, is it possible without giving Instance of Class A?

please let me know thanks

解决方案

Is not possible, because the event is a method that belong the class A, so in order to access a non static member of any class, you must have an object of that class and that member have to be public (if your class is not inherit the class A, otherwise could also be protected or internal)!


这篇关于ButtonClick事件访问没有Class实例在另一个Class中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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