gpt4 book ai didi

windows - 静态类和 "this"关键字

转载 作者:可可西里 更新时间:2023-11-01 12:01:26 26 4
gpt4 key购买 nike

我有一个带有自定义事件的静态类,如下所示:

    //The delegate
public static delegate void eventDoneDelegate(object sender, WebLoaderEventArgs e);

//The event that uses the delegate
public static event eventDoneDelegate PageRequestDone;

//Calls the event
private static void onPageRequestDoneChanged(WebLoaderEventArgs e)
{
if (PageRequestDone != null)
PageRequestDone(this, e);
}

我知道不能使用“this”,因为它引用了当前实例,但我如何将当前类作为参数传递?

也许我的逻辑是错误的,请注意我,因为我是新手。

谢谢。

最佳答案

sender 参数值的语义取决于事件发布者和事件订阅者之间的模糊约定;没有通用的标准。在您的示例中,我根本看不到发送者值的任何必要性,您不妨传递 null。

关于windows - 静态类和 "this"关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9489127/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com