using System; using System.Collections.Generic; using System.Linq; using System.Text;namespace WindowsFormsApplication2 { public class testA { private testB _tb; public testA() { this._tb = new testB(); this._tb.onB+=new testB.onBHander(onB); this._tb.exec(); } private void onB(object sender, string a) { Console.WriteLine(a); } } public class testB { public delegate void onBHander(object sender, string a); public event onBHander onB; private testC _tc; public testB() { if(this._tc==null) this._tc = new testC(); this._tc.onC += new testC.onCHandler(onC); } public void exec() { this._tc.test1(); } private void onC(object sender, string a) { if (onB != null) { onB(sender, a); } } } public class testC { public delegate void onCHandler(object sender, string a); public event onCHandler onC; public void test1() { if (onC != null) onC(this, "a"); } } }
using System.Collections.Generic;
using System.Linq;
using System.Text;namespace WindowsFormsApplication2
{
public class testA
{
private testB _tb; public testA()
{
this._tb = new testB();
this._tb.onB+=new testB.onBHander(onB);
this._tb.exec();
} private void onB(object sender, string a)
{
Console.WriteLine(a);
} } public class testB
{
public delegate void onBHander(object sender, string a);
public event onBHander onB; private testC _tc; public testB()
{
if(this._tc==null)
this._tc = new testC();
this._tc.onC += new testC.onCHandler(onC); }
public void exec()
{
this._tc.test1();
}
private void onC(object sender, string a)
{
if (onB != null)
{
onB(sender, a);
}
}
} public class testC
{
public delegate void onCHandler(object sender, string a);
public event onCHandler onC; public void test1()
{
if (onC != null)
onC(this, "a");
}
}
}