You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.1 KiB

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DelegateEventFuncAction
{
public class DelegateTest
{
public delegate void FunctionPointer();
private static void Print1()
{
Console.WriteLine("Print 1");
}
private static void Print2()
{
Console.WriteLine("Print 2");
}
private static void Print3()
{
Console.WriteLine("Print 3");
}
private static void Print4()
{
Console.WriteLine("Print 4");
}
private static void Execute(FunctionPointer fp)
{
fp();
}
public static void DoTest1()
{
Execute(Print1);
Execute(Print2);
Execute(Print3);
Execute(Print4);
}
public static void DoTest2()
{
// delegate chain
FunctionPointer fp = new FunctionPointer(Print1);
fp += Print2;
fp += Print3;
fp += Print4;
fp();
}
}
}