0
我嘗試這樣做:我的委託類型不工作「有望方法名」
class Program
{
public delegate int add(int x, int y);
public class ff
{
public static int addNumbers(int x, int y)
{
return x + y;
}
public static int substractNumbers(int x, int y)
{
return x - y;
}
static void Main(string[] args)
{
Delegate delegare = new add(ff.addNumbers);
Console.WriteLine(delegare(3,4));
}
}
我不明白爲什麼我得到這個錯誤「預期的方法名」。 當我使用具有void函數的委託時,它可以工作。 有人可以幫我嗎?
噢,對,非常感謝。 –