当前位置: 移动技术网 > IT编程>开发语言>.net > 遍历结构体内部元素和值(Name and Value)

遍历结构体内部元素和值(Name and Value)

2019年03月23日  | 移动技术网IT编程  | 我要评论

临猗政府网,赵晗微博,素菜魔兽

代码:
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";
  }
 
运行结果:

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网