using
System;
public
delegate
void
fnTwoInteger(
int
x,
int
y);
public
class
DelegateExample
{
public
static
void
Main()
{
ExmapleClass obj =
new
ExmapleClass();
fnTwoInteger pointer=
null
;
pointer +=
new
fnTwoInteger(obj.Add);
pointer +=
new
fnTwoInteger(obj.Multiply);
pointer(52, 72);
Console.ReadLine();
}
}
public
class
ExmapleClass
{
public
void
Add(
int
x,
int
y)
{
Console.WriteLine(
"The sum is: "
+ (x + y));
}
public
void
Multiply(
int
x,
int
y)
{
Console.WriteLine(
"The product is: "
+ (x * y));
}
}
Output:
The sum is: 124
The product is: 3744
No comments:
Post a Comment