对于设计模式我是初学者,没想到最简单的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