using System;
namespace ConsoleApplication19
{
class Program //so easy
{
public delegate void Del(string message);
public static void DelegateMethod(string message)
{
Console.WriteLine(message);
}
public static void MethodWithCallback(int param1, int param2, Del callback)
{
callback("The number is: " + (param1 + param2).ToString());
}
static void Main(string[] args)
{
// Instantiate the delegate.
Del handler = DelegateMethod;
// Call the delegate.
//handler("Hello World");
MethodWithCallback(1, 2, handler);
}
}
}
C# 委托的使用(指向函数的指针)
最新推荐文章于 2024-06-26 16:22:54 发布