hi,
how to perform math operations like addition, subtraction, multiplication and division using delegates and events where all operations are treated separately.
I tried like this -- here I gave Math as eventargs in delegate declaration and I created a math class which refer eventargs. but in class I am not able to write the methods for individual arithmetic operations. I want to raise an event using Math class object.
public delegate void MathOperationHandler(object sender,Math m)
public event MathOperationHandler op
{
add
{
Events.AddHandler(key, value);
}
remove
{
Events.RemoveHandler(key, value);
}
}
public class Math : EventArgs
{
double n1 = double.MaxValue;
double n2 = double.MaxValue;
public Math(double num1, double num2)
{
this.n1 = num1;
this.n2 = num2;
}
public double num1
{
get { return num1; }
}
public double num2
{
get { return num2; }
}
}
private void RaiseEvent(Math m)
{
if (Events[key] != null)
{
(Events[key] as MathOperationHandler)(this, m);
}
}
Am I doing correctly . please, help me....
Loading
Master BillaPosted Sep 1, 2009, 10:57 AM
You can refer this
http://www.c-sharpcorner.com/UploadFile/rmcochran/delegateStrategy06142007210551PM/delegateStrategy.aspx
thank you
srinathPosted Sep 2, 2009, 5:59 AM
In the same way, I tried a lot for "typing an sms" as we do in mobile phone using delegate and events where button keypress will happen 3 or 4 times. for example, if we press button '9', we get 'w', and if we press the same button continuously for 2 times, we get 'x' and so on... . This is to be done in windows application. I am not able to get it.
Please help me......