如下:
       /// <summary>
       /// 主机MAC
       /// </summary>
       public string Host { get; set; }我现在知道了Host后,可不可获取到“主机MAC”这几个字啊?

解决方案 »

  1.   

    Debug版本好像不会删除注释,不过你好像也拿不到这个注释.release版本会删除掉代码中的注释的.
      

  2.   

    PropertyInfo[] peroperties = typeof(TEST).GetProperties(BindingFlags.Public | BindingFlags.Instance);        foreach (PropertyInfo property in peroperties)
            {
                object[] objs = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
                if (objs.Length > 0)
                {
                    Console.WriteLine("{0}: {1}", property.Name, ((DescriptionAttribute)objs[0]).Description);
                }
            }
            Console.ReadKey();
    class TEST
    {
        [Description("a")]
        public string X
        {
            get { return null; }
        }
    }
      

  3.   

    在 Visual C# 中,可以为代码创建文档,方法是在 XML 标记所指的代码块前面,直接在源代码的特殊注释字段中包括 XML 标记 
    XML doc 注释不是元数据;它们不包括在编译的程序集中,因此无法通过反射对其进行访问