对于一些"大对象"的创建,我们常常希望延迟加载,即在需要的时候再创建对象实例。现在Lazy<T>很好地支持了这一特点。主要包括:

 

 

public class LazySinleton
{
    private LazySingleton()
    {}
 
    public static LazySingleton Instance
    {
        get
        {
            return Lazy.data;
        }
    }
 
    private class Lazy
    {
        static Lazy()
        {}
 
        internal static readonly LazySingleton data = new LazySingleton();
    }
}
 

相关文章:

  • 2022-02-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-28
  • 2021-11-22
  • 2021-08-19
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-21
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-12-19
  • 2021-11-28
相关资源
相似解决方案