C# code

public void ff(Object objInit, Object[] obj, string[] items) { List<string> itemList = new List<string>(items); foreach( PropertyInfo pi in objInit.GetType().GetProperties()) { int idx = itemList.IndexOf(pi.Name); if (idx >= 0) { pi.SetValue(objInit, obj[idx], null); } } }

C# code
public void ff(Object objInit, Object[] obj, string[] items) { for (int i = 0; i < obj.Length; i++) { foreach (MemberInfo mi in objInit.GetType().GetMember(items[i])) { objInit.GetType().GetProperty(mi.Name).SetValue(objInit, obj[i],null); } } }

相关文章:

  • 2021-11-05
  • 2021-09-17
  • 2022-01-12
  • 2022-03-08
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案