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
Tangara G
NA
298
94k
Dun understand why Add when it should be Substrate
Nov 8 2016 10:02 PM
Dear experts,
I have this multi-cast delegate which I am having problem understand:
delegate
void
M(
int
x,
int
y);
public
class
Oper
{
public
static
void
Add(
int
x,
int
y)
{
Console.WriteLine(
"{0} + {1} = {2}"
, x, y, x+y);
}
public
static
void
Sub(
int
x,
int
y)
{
Console.WriteLine(
"{0} + {1} = {2}"
, x, y, x+y);
}
public
class
CSharpApp
{
static
void
Main()
{
M del =
new
M(Oper.Add);
del +=
new
M(Oper.Sub);
del(6,4);
del -=
new
M(Oper.Sub);
del(2,8);
}
}
I would like to know why the output for del(2,8) is 10 instead of 2 - 8 which is -6.
Reply
Answers (
7
)
MVC Validation Web Form
VS 2012 change project folder location