vb.net类之间的事件

来源:百度知道 编辑:UC知道 时间:2024/06/18 12:43:05
我有两个自定义类ClassA和ClassB
请问怎么才能在ClassA中自定义一个事件,当事件触发时,ClassB立即得到通知?
要使用delegate吗?请简略写一下代码,谢谢
1楼的大哥,你写的我完全不明白有什么用处

class b
public shared sub rell()
....
end sub
end class

class A
public event danger() '事件
public n as integer
if n>10 then
raiseevent danger()
end if
end classs

sub main()
dim a1 as new A()
'--通过A类danger事件地址B类rell事件地址
addhandler a.danger,addressof b.rell
a.n=100
end sub

public ClassB getClassB()
{
if(true)
{
ClassB cb=new ClassB();
return cb;
}
}

有点难.刚学的..也不懂...