对于设计模式我是初学者,没想到最简单的Singleton都有这么多变化,下面恐怕是代码最少的了

C#代码
public sealed class Singleton
{
   private static readonly Singleton instance = new Singleton();
   private Singleton(){}
   public static Singleton Instance
   {
      get 
      {
         return instance; 
      }
   }
}

VB.NET代码
Public NotInheritable Class Singleton
 Private Shared ReadOnly instance As Singleton = New Singleton

 Private Sub New()
 End Sub

 Public Shared ReadOnly Property Instance() As Singleton
  Get
   Return instance
  End Get
 End Property
End Class

http://www.microsoft.com/china/msdn/library/architecture/patterns/esp/ImpSingletonInCsharp.mspx

相关文章:

  • 2021-12-07
  • 2021-10-16
  • 2021-06-25
猜你喜欢
  • 2021-11-21
  • 2021-11-08
  • 2021-12-26
  • 2022-02-08
  • 2022-01-20
  • 2021-08-17
  • 2022-02-17
相关资源
相似解决方案