本文共 671 字,大约阅读时间需要 2 分钟。
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); } }}
转载地址:http://ptdaf.baihongyu.com/