How to have comments in IntelliSense for function

2019-01-16 06:48发布

In Visual Studio and C#, when using a built in function such as ToString(), IntelliSense shows a yellow box explaining what it does.

alt text alt text

How can I have that for functions and properties I write?

12条回答
姐就是有狂的资本
2楼-- · 2019-01-16 07:21

Solmead has the correct answer. For more info you can look at XML Comments.

查看更多
家丑人穷心不美
3楼-- · 2019-01-16 07:22

Define Methods like this and you will get the help you need.

    /// <summary>
    /// Adds two numbers and returns the result
    /// </summary>
    /// <param name="first">first number to add</param>
    /// <param name="second">second number to </param>
    /// <returns></returns>
    private int Add(int first, int second)
    {
        return first + second;
    }

Screenshot of the code usage

查看更多
看我几分像从前
4楼-- · 2019-01-16 07:23

Also the visual studio add-in ghost doc will attempt to create and fill-in the header comments from your function name.

查看更多
我想做一个坏孩纸
5楼-- · 2019-01-16 07:25

read http://msdn.microsoft.com/en-us/library/3260k4x7.aspx Just specifying the comments will not show the help comments in intellisense.

查看更多
Luminary・发光体
6楼-- · 2019-01-16 07:26

In CSharp, If you create the method/function outline with it's Parms, then when you add the three forward slashes it will auto generate the summary and parms section.

So I put in:

public string myMethod(string sImput1, int iInput2)
{
}

I then put the three /// before it and Visual Studio's gave me this:

/// <summary>
/// 
/// </summary>
/// <param name="sImput1"></param>
/// <param name="iInput2"></param>
/// <returns></returns>
public string myMethod(string sImput1, int iInput2)
{
}
查看更多
倾城 Initia
7楼-- · 2019-01-16 07:30

To generate an area where you can specify a description for the function and each parameter for the function, type the following on the line before your function and hit Enter:

  • C#: ///

  • VB: '''

See Recommended Tags for Documentation Comments (C# Programming Guide) for more info on the structured content you can include in these comments.

查看更多
登录 后发表回答