using System; using Namotion.Reflection; namespace ConsoleApp1 { class Program { static void Main(string[] args) { string studentSummary = typeof(Student).GetXmlDocsSummary(); Console.WriteLine(studentSummary); var piList = typeof(Student).GetProperties(); foreach (var pi in piList) { var summary = pi.GetXmlDocsSummary(); Console.WriteLine($"{pi.Name}-->{summary}"); } } } /// <summary> /// 学生信息 /// </summary> public class Student { /// <summary> /// Id /// </summary> public int Id { get; set; } /// <summary> /// 姓名 /// </summary> public string Name { get; set; } /// <summary> /// 性别 /// </summary> public string Sex { get; set; } } }
使用组件Namotion.Reflection,同时需要在项目属性中开启生成xml启动项
运行结果:
学生信息 Id-->Id Name-->姓名 Sex-->性别