C# 通用单例窗体类

    /// <summary>
    /// 通用的单例制作器
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class UniversalSingletonGeneator<T> where T : Form,new()
    {
        private static T t = null;
        public static T CreateSingleton()
        {
            if (t == null || t.IsDisposed)
            {
                t = new T();
            }
            t.WindowState = FormWindowState.Normal;
            t.Activate();
            return t;
        }
    }

   // 测试代码
    var pFrm = UniversalSingletonGeneator<Form1>.CreateSingleton();
    pFrm.Show();
原文地址:https://www.cnblogs.com/MaFeng0213/p/9272069.html