下面是我在 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# 新手