TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
srinath
NA
144
0
delegate and event for mathoperation
Sep 1 2009 7:09 AM
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....
Reply
Answers (
2
)
About Image comparision of images taken from the webcam
mouse scroll