以编程方式触发事件?

soo*_*ise 7 c# events

如何以编程方式调用此方法?如果我简单地做KillZombies(),它说我没有正确的参数,但我不知道当我只是使用代码时要指定的参数...

public static void KillZombies(object source, ElapsedEventArgs e)
{
    Zombies.Kill();
}
Run Code Online (Sandbox Code Playgroud)

p.c*_*ell 6

你有没有尝试过:

KillZombies(null, null);
Run Code Online (Sandbox Code Playgroud)

也许重构你的设计:

public static void KillZombies(object source, ElapsedEventArgs e)
{
    //more code specific to this event, logging, whathaveyou.
    KillSomeZombies();
}

public static void KillSomeZombies()
{
    Zombies.Kill();
}

//elsewhere in your class:
KillSomeZombies();
Run Code Online (Sandbox Code Playgroud)