public class Test { public void MyObj<T>() where T : class { //T t = new T(); T t =System.Activator.CreateInstance<T>(); //获取类型跟字段然后拿到对应名字方法跟字段就可以了 } } 微信官方创建实体的方法,通过泛型类型创建实例System.Activator.CreateInstance<T>(); 新增: public static void Ad
Creating Objects 创建对象 There are two main ways to create an object. The first is the one you saw before: 创建对象主要有两种方法.第一种如下: NSString* myString = [NSString string]; This is the more convenient automatic style. In this case, you are creating an autorel