gpt4 book ai didi

c# - 识别C#源代码中的注释

转载 作者:行者123 更新时间:2023-12-03 19:22:18 29 4
gpt4 key购买 nike

如何识别C#源代码中的注释?我想检索评论中的所有信息。

public class TestClass
{
/// <summary>
/// Sample method
/// </summary>
/// <param name="a">1 argument</param>
/// <param name="b">2 argument</param>
/// <param name="c">3 argument</param>
/// <returns>true or false</returns>
/// <exception cref="NotImplementedException">Always throw exception</exception>
public bool Method(int a, object b, Panel c)
{
throw new NotImplementedException();
}
}
  1. 方法说明 - “示例方法”
  2. 参数说明 - “1 个参数,...”
  3. 返回值的描述 - “true 或 false”
  4. 异常类型和描述
  5. 其他用户标签

最佳答案

最简单的方法是启用 xml 注释生成(项目属性 -> 构建),并解析 xml 文件...

<?xml version="1.0"?>
<doc>
<assembly>
<name>ClassLibrary2</name>
</assembly>
<members>
<member name="M:TestClass.Method(System.Int32,System.Object,System.Windows.Forms.Panel)">
<summary>
Sample method
</summary>
<param name="a">1 argument</param>
<param name="b">2 argument</param>
<param name="c">3 argument</param>
<returns>true or false</returns>
<exception cref="T:System.NotImplementedException">Always throw exception</exception>
</member>
</members>
</doc>

关于c# - 识别C#源代码中的注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/693812/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com