Mic*_*ber 2 c# visual-studio-2008
如何识别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();
}
}
Run Code Online (Sandbox Code Playgroud)
最简单的方法是启用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>
Run Code Online (Sandbox Code Playgroud)