📜  如何在 C# 代码示例中创建委托

📅  最后修改于: 2022-03-11 14:49:11.630000             🧑  作者: Mango

代码示例1
//the delegate can point to a void function and takes a string parameter
delegate void Del(string str);

public void hello(string Name)
{
     Console.WriteLine("hello " + Name) ;
}
public static void main()
{
  //you need to declare the delegate type above and give it a function
  //that matches the delegate's funcion 
  Del HelloDelegate = new Del(hello);
  HelloDelegate("IC");
}
/// (output) -> "hello IC"