特性:C#特性(Attribute)_寒冷的晚风的博客-优快云博客
反射:是一种机制,允许在运行时获取和操作类型、成员和对象的信息
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AtrributeTest
{
internal class Program
{
static void Main(string[] args)
{
HelpAttribute help;
foreach(HelpAttribute attr in typeof(MyClass).GetCustomAttributes(true))//遍历类的属性
{
help = attr;
if(help != null)
{
Console.WriteLine("Description:{0}",help.Description);
Console.WriteLine("Name:"+ help.Name);