我在Visual Studio中应该如何注释一个方法,以便在选择该方法时能够在工具提示中看到我的描述?
我在Visual Studio中应该如何注释一个方法,以便在选择该方法时能够在工具提示中看到我的描述?
您使用带有3个斜杠(///)的XML文档注释。
/// <summary>
/// Description for SomeMethod.</summary>
/// <param name="s"> Parameter description for s goes here</param>
/// <seealso cref="String">
/// You can use the cref attribute on any tag to reference a type or member
/// and the compiler will check that the reference exists. </seealso>
public void SomeMethod(string s)
{
}
这里你可以找到一个教程,其中包含许多示例,用于介绍这种类型的文档注释。
///
),它将展开为一个 XML 文档注释的模板。您在 summary
部分填写的任何内容都将显示在工具提示中。/// <summary>
/// Always returns 1
/// </summary>
private Int32 MyMethod()
{
return 1;
}
对我来说,在以下方式中也是如此(在VS 2008中):
void foo
(int x)
/*
Function description here
*/
{
}
/// <calculate volume>
///
/// </volume>
/// <lenght lenght="num1"></toconvert>
/// <width width="num2"></convert>
/// <hight height="num3"></volume>
public static void VolBox(int num1, int num2,int num3)
{
//looks for imput tofind volume of rectangular box
int volume;
volume = num1 * num2 * num3;
Console.WriteLine("the volume of your rectangle box is {0} .",volume);
}
GhostDoc
。 - Hans Kesting