2024年1月25日发(作者:)
c#遍历对象属性给对象赋值using System;using c;using ;using ;using ;using trols;
namespace WebApplication33{ public partial class Default : { protected void Page_Load(object sender, EventArgs e) { Values item = SetValues(); PrintValues(item); } ///
public int Value8 { get; set; } public int Value9 { get; set; } public int Value10 { get; set; } }}————————————————public class PP 2 { 3 public string a { get; set; } 4 public string b { get; set; } 5 public string c { get; set; } 6 } 7 class Program 8 { 9 static void Main(string[] args)10 {11 Hashtable ht = new Hashtable();12
13
14 ("a", "utf8");15 ("b", "xxxx");16 ("c", "xxxx");17 PP config = new PP();18 PropertyInfo[] propertys = e().GetProperties();19 foreach (PropertyInfo property in propertys)20 {21 for (int i = 0; i < ; i++)22 {23 ue(config, ht[].ToString(), null);24 }25 }26 ine(config.a+"t"+config.b);27 ne();28 }29 }


发布评论