62,047
社区成员
发帖
与我相关
我的任务
分享
//默认的方式,用一个现有字符数组创建
string s = System.Activator.CreateInstance(Type.GetType("System.String"), new object[] { "初始化的字符串,可以为空".ToCharArray() }) as string;
//使用一个字符+一个重复长度创建
string s1 = System.Activator.CreateInstance(Type.GetType("System.String"), new object[] { 'a',50 }) as string;
string[] s = System.Activator.CreateInstance(Type.GetType("System.String[]"), new object[] { 1 }) as string[];