You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using System;
- using System.Collections.Generic;
- using System.Text;
-
- namespace HBLConsole.Service
- {
- /// <summary>
- /// 单例对象基类
- /// </summary>
- /// <typeparam name="T"></typeparam>
- public class Singleton<T> where T : new()
- {
- private static object _async = new object();
-
- private static T _instance;
-
- static readonly Lazy<T> instance = new Lazy<T>();
- /// <summary>
- /// 获取实例
- /// </summary>
- /// <returns></returns>
- public static T GetInstance()
- {
- return instance.Value;
- }
- }
- }
|