遍历结构体中的变量
2016-03-17 23:32
344 查看
public struct Site
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string Country;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string StationNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string RadarType;
public int LongitudeValue;
public short MangFreq;
}
for ()
{
//遍历结构体中的变量
}
遍历结构体成员名称
foreach (System.Reflection.FieldInfo fieldInfo in typeof(Site).GetFields())
{
System.Console.Write(fieldInfo.Name);
}
C# code
?
遍历结构体实例成员值
foreach (System.Reflection.FieldInfo fieldInfo in typeof(Site).GetFields())
{
System.Console.Write(fieldInfo.GetValue(site对象实例).ToString());
}
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string Country;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)]
public string StationNumber;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 20)]
public string RadarType;
public int LongitudeValue;
public short MangFreq;
}
for ()
{
//遍历结构体中的变量
}
遍历结构体成员名称
foreach (System.Reflection.FieldInfo fieldInfo in typeof(Site).GetFields())
{
System.Console.Write(fieldInfo.Name);
}
C# code
?
foreach (System.Reflection.FieldInfo fieldInfo in typeof(Site).GetFields())
{
System.Console.Write(fieldInfo.GetValue(site对象实例).ToString());
}
相关文章推荐
- Android——onCreate( )方法详解(转)
- String、StringBuffer与StringBuilder之间区别
- 通过storyboard找到视图控制器
- 前台传数组后台list接收
- java继承中的this用法
- utilities——C++常用仿函数(二)
- 简单查询笔记
- C# Bitmap类型与Byte[]类型相互转化
- 本文介绍C# BitmapData
- MongoDB初识
- Android——OnCreate
- UITableViewCell和UICollectionViewCell创建的三种方式及应用选择
- 彩色跑马灯TextView
- 《Effective C++》学习笔记——条款42
- java第一步
- iOS中数据存储方式
- Android Transition框架使用--Demo(2)
- NET MVC异常处理模块
- C#多线程学习(六) 互斥对象
- C# List 复制克隆副本