我目前是一名编程学生,显然我的问题很简单,但我无法在网上找到答案。所以这就是:
在XML /// C#中的评论中,<returns>
标记显示在哪里,我知道当您将鼠标悬停在方法调用上时,<summary>
标记中包含的所有内容都会显示在intellisense中,但不是return标签。
那么<returns>
标记在哪里?
感谢。
答案 0 :(得分:32)
当您在View&gt;&gt;中看到方法时对象浏览器
例如你会看到这样的东西:
private int GetColumnIndex(Microsoft.Office.Interop.Excel.Worksheet worksheet, string columnName, int rowIndex, int startColumnIndex)
Member of MyAddIn.CommandHandlers.CommandHandler
Summary:
Returns the column index with specified name and in specified row
Parameters:
worksheet: Target worksheet
columnName: Column name to find
rowIndex: Row index in which to search the column
startColumnIndex: Start index of the column
Returns:
The index of column if found, else returns 0
答案 1 :(得分:7)
如果您根据评论生成API文档,则会在备注部分之前的返回值部分as seen here中显示。
答案 2 :(得分:7)
当您选择在编译时构建XML文档文件时,XML文档注释中包含的所有内容都会被复制到该文件中。像Sandcastle这样的程序可以构建类似于MSDN的HTML文档。
据我所知,它并没有在Visual Studio自己的IntelliSense中显示。但那不是在那里写东西的借口:-)。 ReSharper的Ctrl + Q例如 显示它。
答案 3 :(得分:1)
其他部分(基本上任何异常summary
)都不会出现在intellisense中。它们仅用于使用Sandcastle等工具在XML生成的文档中出现。
答案 4 :(得分:0)
对于那些可能会尝试找到东西的人。这可能不是最好的方法,但是恕我直言,当将鼠标悬停在方法名称上时,它确实使方法变得更容易理解。
/// <summary>
/// Adds a new post given the mapped PostDTO and userId <br></br><br></br>
/// <b>Returns</b> the newly created object, otherwise null.
/// </summary>
/// <param name="postDTO"></param>
/// <param name="userId"></param>
PostDTO addPost(PostDTO postDTO, long userId);
通过这种方式,您可以在VS中(至少在VS 2019中)看到下图所示的图像,以我的经验,当试图理解他人编写的代码时,至少您可以说出期望的内容, {1}}或object
,或任何情况。
我希望它可能对其他人有用。