Type t = typeof(CommonController); StringBuilder str = new StringBuilder(); MethodInfo[] methors = t.GetMethods(BindingFlags.Instance | BindingFlags.Public); var md = t.GetCustomAttribute<System.ComponentModel.DescriptionAttribute>(); str.AppendFormat("路由:" + t.Name).AppendLine(""); str.AppendFormat("描述" + md.Description).AppendLine(""); foreach (var v in methors) { var af = v.GetCustomAttribute<Models.Attribute.APIFunctionAttribute>(); if (af != null) { str.AppendFormat(" 功能标识:{0}", v.Name).AppendLine(""); str.AppendFormat(" 功能描述:{0}", af.Description).AppendLine(""); ParameterInfo[] ps = v.GetParameters(); str.AppendFormat(" 参数:总数{0}", ps.Length).AppendLine(""); foreach (ParameterInfo p in ps) { str.AppendFormat(" 名称{0}", p.Name).AppendLine(""); str.AppendFormat(" 类型{0}", p.ParameterType.FullName).AppendLine(""); } }