c# - 单例对象生命周期是进程还是appdomain?

标签 c# asp.net singleton

最近我在面试中被问到一个问题

Singleton pattern guarantees creating only a single object of a class in a process or app domain level?

最佳答案

关于静态字段的 C# 规范指出:

I.8.4.3 Static fields are always restricted to a single application domain basis (see §I.12.5), but they can also be allocated on a per-thread basis

您可以获得更多信息reading the CLI spec .

关于c# - 单例对象生命周期是进程还是appdomain?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58711990/

相关文章:

ruby - 哪个是 Ruby 中最好/最常用的单例编码约定?

ios - 如何在 swift 的单例中使用此代码?

c# - 这是实现线程安全读/写 Guid 属性的正确方法吗?

c# - Serenity MVC 框架使用 Web 服务

javascript - 如何使用 breezejs 保护添加或删除实体

asp.net - ASP Response.Flush() 刷新部分数据

asp.net - 使用 Entity Framework 在 asp.net mvc3 中的多个 xml 文档上运行 xpath 查询

singleton - 当对象被放置在依赖注入(inject)容器中时,你如何处理 CA2000(处理 IDisposable 对象)?

c# - 使用 C# 异步、等待在 Azure 上通过 SendGrid 发送电子邮件

c# - 如何使用样式和 DataTrigger 绑定(bind)到 XAML 中的项目源计数?