// custom object
public class Car {
private int tank;
// delegate declaration
public delegate void ChangingHandler (object sender, CarArgs ca);
// event declaration
public event ChangingHandler Change;
public Car(int n) {
this.tank=n;
}
public void SetTank(int p) {
this.tank=p;
// call the event
if (p<5) {
CarArgs ca=new CarArgs("Tank is below 5, tank value is : "+this.tank);
Change(this,ca);
}
}
public string GetTank() {
return this.tank.ToString();
}
}
No comments:
Post a Comment