Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
7
Reply
Dun understand why Add when it should be Substrate
Tangara G
Nov 8 2016 10:02 PM
223
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
7
)
Next Recommended Forum
MVC Validation Web Form
VS 2012 change project folder location