I think you need to create Operator(++) overloading class with Events..
try this:-
using System;
namespace WindowsFormsApplication1
{
class PlusPlusOperatorOver
{
int num;
public event NumEvHndlr NumEv;
public PlusPlusOperatorOver(int num)
{
this.num = num;
}
public void NumTest(int n)
{
if (n == 5 && this.NumEv != null)
NumEv(this, new EvArg(n));
}
public static PlusPlusOperatorOver operator ++(PlusPlusOperatorOver ppo)
{
ppo.num++;
ppo.NumTest(ppo.num);
return ppo;
}
public delegate void NumEvHndlr(object sender, EvArg e);
public void Reset() {
num = 0;
}
}
public class EvArg : EventArgs
{
private int _Num;
public EvArg(int num) { this._Num = num; }
public int NUMget
{
get { return _Num; }
}
}
}
Use in the form class:-
using System;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
plus.NumEv += new PlusPlusOperatorOver.NumEvHndlr(this.EvHppn);
}
private void button1_Click(object sender, EventArgs e)
{
plus++;
}
PlusPlusOperatorOver plus = new PlusPlusOperatorOver(0);
int t = 0;
private void EvHppn(object sender, EvArg e)
{
MessageBox.Show(sender.ToString() + e.NUMget);
label1.Text = t.ToString();
plus.Reset();
}
private void button2_Click(object sender, EventArgs e)
{
plus++;
}
}
}
I hope this will help you..