c# 泛型new T

        /// <summary>
        /// 获取Service层的类实例,在没有写配置文件时使用
        /// </summary>
        /// <typeparam name="T">当前传入的类名</typeparam>
        /// <returns>类实体</returns>
        public static T CreateInstance<T>() where T : new()
        {
            return new T();
        }
原文地址:https://www.cnblogs.com/a735882640/p/9639816.html