c#-如果从静态构造函数调用静态事件有什么缺点

标签 c#

从静态构造函数分配静态事件有什么缺点吗?

例如:

public class static Test()
{
    static Test()
    {
        AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload;
    }

    static void CurrentDomain_DomainUnload(object sender, EventArgs e)
    {
        CleanUp();
    }
}

最佳答案

Is there is any disadvantages using ...

不,订阅事件就可以了。

提高它会出现问题,但这并不适用于此。

关于c#-如果从静态构造函数调用静态事件有什么缺点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45790665/

相关文章:

c# - XDocument.Descendants() 与 DescendantNodes()

c# - 如何在 Webview2 中使用透明度?

c# - 多线程文件搜索 C#

C# WPF 参数异常 : Specified Visual is already a child of another Visual or the root of a CompositionTarget

c# - 如何为 WebApiConfig 配置路由以将某些请求重定向到静态 html 页面?

c# - 如何使用预构建类设置事件处理

c# - Web 服务拒绝访问

c# - RestSharp 在等待响应时无法转换对象

c# - 实例化一颗子弹朝向玩家位置

c# - 你如何用 Rhino Mocks stub IQueryable<T>.Where(Func<T, bool>)?