35 使用default为泛型类型变量指定初始值

因为值类型的变量的默认初始值是0,而引用类型的变量的默认初始值是null:

        public T Func<T>()
        {
            T t = default(T);
            return t;
        }

 

posted @ 2016-01-20 16:42  小-黑  阅读(111)  评论(0)    收藏  举报