谢谢你的帮助,
〜在圣地亚哥
List<SimpleAddress> addresses = new List<SimpleAddress>();string addresspropertyPattern = "Address{0}";string namePropertyPattern = "Address{0}name";string descPropertyPattern = "Address{0}Desc";for(int i = 1; i <= MAX_ADDRESS_NUMBER; i++){ System.Reflection.PropertyInfo addressproperty = typeof(AddressList).GetProperty(string.Format(addresspropertyPattern,i)); System.Reflection.PropertyInfo nameProperty = typeof(AddressList).GetProperty(string.Format(namePropertyPattern,i)); System.Reflection.PropertyInfo descProperty = typeof(AddressList).GetProperty(string.Format(descPropertyPattern,i)); SimpleAddress address = new SimpleAddress(); address.Address = (string)addressproperty.GetValue(yourAddressListObject,null); address.name = (string)nameProperty.GetValue(yourAddressListObject,null); address.Description = (string)descProperty.GetValue(yourAddressListObject,null); addresses.Add(address);}总结
以上是内存溢出为你收集整理的c# – 反思帮助.根据类的属性从类中创建一个集合?全部内容,希望文章能够帮你解决c# – 反思帮助.根据类的属性从类中创建一个集合?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)