zoukankan      html  css  js  c++  java
  • 遍历结构体中的变量

    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 
     
     ?
    1
    2
    3
    4
    foreach  (System.Reflection.FieldInfo fieldInfo  in  typeof (Site).GetFields())
    {
         System.Console.Write(fieldInfo.Name);
    }
    遍历结构体实例成员值
    foreach (System.Reflection.FieldInfo fieldInfo in typeof(Site).GetFields())
    {
      System.Console.Write(fieldInfo.GetValue(site对象实例).ToString());
    }
     
  • 相关阅读:
    地狱少女....
    火影忍者 是时候结束了
    1942
    待查
    什么是傻瓜
    公车艳遇
    初一
    继承
    第四周学习笔记
    查找里程————mooc《面向对象程序设计——Java语言》-(浙大翁凯)第三周编程题
  • 原文地址:https://www.cnblogs.com/gosteps/p/5290017.html
Copyright © 2011-2022 走看看