发布时间:2019-09-22整理:admin阅读:
private static Singleton1 instance = new Singleton1();
public static Singleton1 Instance
{
get
{
return instance;
}
}
}
public sealed class Singleton2
{
Singleton2()
{
Console.WriteLine("Singleton2 constructed");
}
public static void Print()
{
Console.WriteLine("Singleton2 Print");
}
public static Singleton2 Instance
{
get
{
return Nested.instance;
}
}
class Nested
{
static Nested() { }
internal static readonly Singleton2 instance = new Singleton2();
}
}
欢迎分享转载→ 程序员面试题精选100题(56)-C/C++/C#面试题(4)(7)