.net之泛型this引用

    using Temptest = Temptest<string>;
    class Program
    {

        static void Main(string[] args)
        {
            Temptest x = new Temptest();
            x.func();
            //输出:
            //ConsoleApplication5.Temptest`1[System.String]
            Console.Read();
        }
    }

     class Temptest <T>{
         /// <summary>
         /// 泛型的this引用
         /// </summary>
         /// <param name="args"></param>
        public T func() {
            Console.Write(this.GetType().ToString());
            return default(T);
            //default表达式对于一个引用类型返回一个null,对于值类型返回一个按位的0.
        }
    }
原文地址:https://www.cnblogs.com/canbefree/p/3498743.html