代码:
DataStruct.MessageStruct ms = new DataStruct.MessageStruct();//实例化结构体
 
//遍历结构体
 foreach (System.Reflection.PropertyInfo p in ms.GetType().GetProperties())
  {
   this.rtbSend.Text += p.Name + "=" + p.GetValue(ms)+"\r\n";
  }
 
运行结果:
遍历结构体内部元素和值(Name and Value)

 

相关文章:

  • 2022-12-23
  • 2022-02-11
  • 2021-12-05
  • 2021-07-03
  • 2021-09-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2021-04-15
  • 2021-04-15
  • 2022-12-23
相关资源
相似解决方案