zoukankan      html  css  js  c++  java
  • Attribute类的使用

    为每个变量设置设置属性 "Description"

    public class PatternOption
        {
            /// <summary>
            /// 方向图步长
            /// </summary>
            [Description("PT_SitaStepDeg")]
            public double StepDeg { get; set; }//
            /// <summary>
            /// 垂直面的切角(phi角)
            /// </summary>
            [Description("PT_VeritalCutPlaneDeg")]
            public double VeritalCutPlaneDeg { get; set; }
            /// <summary>
            /// 垂直面的切角(sita角)
            /// </summary>
            [Description("PT_HorizontalCutPlaneDeg")]
            public double HorizontalCutPlaneDeg { get; set; }
            /// <summary>
            /// 主瓣搜索起点
            /// </summary>
            [Description("PT_MBStartDeg")]
            public double MainbeamSearchStartDeg { get; set; }//
            /// <summary>
            /// 主瓣搜索终点
            /// </summary>
            [Description("PT_MBStopDeg")]
            public double MainbeamSearchStopDeg { get; set; }//   
    
            /// <summary>
            /// 上旁瓣搜索起点,相对于主瓣方向,deg
            /// </summary>
            [Description("PT_UBOffsDeg")]
            public double UBStartOffsetFromMainBeamDeg { get; set; }
            /// <summary>
            /// 上旁瓣搜索终点偏移量,相对于主瓣方向,def
            /// </summary>
            [Description("PT_SitaStepDeg")]
            public double UBEndOffsetFromMainBeamDeg { get; set; }//
    
            [Description("PT_UBOffsDeg")]
            public bool UBCorrectToEdge { get; set; }
            
           
           
        }

    通过反射读取 Description

     #region 读取属性描述的例程,
                PatternOption patternOption = new PatternOption();
                Type type = patternOption.GetType();
                FieldInfo[] fieldInfos = type.GetFields();
                foreach (FieldInfo item in fieldInfos)
                {
                    DescriptionAttribute[] attributes = (DescriptionAttribute[])item.GetCustomAttributes(typeof(DescriptionAttribute), false);
                } 
                #endregion
  • 相关阅读:
    表单提交方式
    js--dom对象
    js--bom对象
    css布局的漂浮、position定位
    python语法学习第五天--lambda表达式、filter()、map()
    python语法学习第五天--函数(2)
    python3语法学习第五天--函数(1)
    python3语法学习第四天--序列
    leetcode| 84. 柱状图中最大的矩形
    leetcode| 56. 合并区间
  • 原文地址:https://www.cnblogs.com/ccjungle/p/11108640.html
Copyright © 2011-2022 走看看