You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/HomeService/Utility/Singleton.cs

27 lines
576 B
C#

2 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace HomeService.Utility
{
/// <summary>
/// 单例模式
/// </summary>
public sealed class Singleton<T> where T:new()
{
private Singleton() { }
public static T Instance
{
get { return SingletonCreator.instance; }
}
internal class SingletonCreator
{
static SingletonCreator() { }
internal static readonly T instance = new T();
}
}
}