泛型T的实用用法
摘要:在asp.net里泛型是一种很方法很高效率的方法, 其中T的用法最可以让程序变的更简洁、代码量更少。使用可变类型,可以引用T接口: public static class PageContext<T> where T : class, new(){ //.....//} 将可变类型实例化: private static T GetInstance() { return (T)Activator.CreateInstance(typeof(T))); } 想得到可变类名可以这样:string typeStr = typeof(T).ToSt...
阅读全文
posted @
2012-02-21 15:29
亲善美
阅读(3683)
推荐(1)