以下是我的c#代码...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
TestPointer test = new TestPointer();
test.function1(function2); // Error here: The name 'function2' does not exist in current context
}
}
class TestPointer
{
private delegate void fPointer(); // point to every functions that it has void as return value and with no input parameter
public void function1(fPointer ftr)
{
fPointer point = new fPointer(ftr);
point();
}
public void function2()
{
Console.WriteLine("Bla");
}
}
如何在主函数中传递函数引用以调用回调函数?……我是c#的新手