VS2010:在预览中查看方法注释?
VS2010: View method comments in preview?
我通常会为我创建的每个方法添加一个简短的描述。当我转到 方法定义 时,我可以阅读此 description/comment 并且我知道该方法的作用。
是否可以在方法预览中看到这些评论?例如,如果我将光标放在调用的方法上,将显示一个带有方法签名的小弹出窗口。光标在方法上时是否也可以看到方法注释?
我不想去实际的方法看看它做了什么。
谢谢。
是的,这是可能的。您需要使用 C# XML Documentation 格式将评论添加为 summary
元素。
class MyClass
{
/// <summary>
/// Does something.
/// </summary>
/// <param name="foo">The input.</param>
/// <returns>The result.</returns>
public int DoSomething(string foo)
{
Console.WriteLine(foo);
return 3;
}
}
根据上述定义的文档,Intellisense 提供以下内容:
使用 XML 评论。当您使用 Intellisense 时,这些应该是可见的。
示例:
/// <summary>
/// This class performs an important function.
/// </summary>
public class MyClass{}
看这里:https://msdn.microsoft.com/en-us/library/vstudio/b2s063f7%28v=vs.100%29.aspx
我通常会为我创建的每个方法添加一个简短的描述。当我转到 方法定义 时,我可以阅读此 description/comment 并且我知道该方法的作用。
是否可以在方法预览中看到这些评论?例如,如果我将光标放在调用的方法上,将显示一个带有方法签名的小弹出窗口。光标在方法上时是否也可以看到方法注释?
我不想去实际的方法看看它做了什么。
谢谢。
是的,这是可能的。您需要使用 C# XML Documentation 格式将评论添加为 summary
元素。
class MyClass
{
/// <summary>
/// Does something.
/// </summary>
/// <param name="foo">The input.</param>
/// <returns>The result.</returns>
public int DoSomething(string foo)
{
Console.WriteLine(foo);
return 3;
}
}
根据上述定义的文档,Intellisense 提供以下内容:
使用 XML 评论。当您使用 Intellisense 时,这些应该是可见的。
示例:
/// <summary>
/// This class performs an important function.
/// </summary>
public class MyClass{}
看这里:https://msdn.microsoft.com/en-us/library/vstudio/b2s063f7%28v=vs.100%29.aspx