How to have comments in IntelliSense for function in Visual Studio?

后端 未结 12 1507
难免孤独
难免孤独 2020-12-04 10:42

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

How can I ha

相关标签:
12条回答
  • 2020-12-04 11:06

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

    0 讨论(0)
  • 2020-12-04 11:11

    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.

    0 讨论(0)
  • 2020-12-04 11:12

    Those are called XML Comments. They have been a part of Visual Studio since forever.

    You can make your documentation process easier by using GhostDoc, a free add-in for Visual Studio which generates XML-doc comments for you. Just place your caret on the method/property you want to document, and press Ctrl-Shift-D.

    Here's an example from one of my posts.

    Hope that helps :)

    0 讨论(0)
  • 2020-12-04 11:15

    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)
    {
    }
    
    0 讨论(0)
  • 2020-12-04 11:15

    All these others answers make sense, but are incomplete. Visual Studio will process XML comments but you have to turn them on. Here's how to do that:

    Intellisense will use XML comments you enter in your source code, but you must have them enabled through Visual Studio Options. Go to Tools > Options > Text Editor. For Visual Basic, enable the Advanced > Generate XML documentation comments for ''' setting. For C#, enable the Advanced > Generate XML documentation comments for /// setting. Intellisense will use the summary comments when entered. They will be available from other projects after the referenced project is compiled.

    To create external documentation, you need to generate an XML file through the Project Settings > Build > XML documentation file: path that controls the compiler's /doc option. You will need an external tool that will take the XML file as input and generate the documentation in your choice of output formats.

    Be aware that generating the XML file can noticeably increase your compile time.

    0 讨论(0)
  • 2020-12-04 11:19

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

    0 讨论(0)
提交回复
热议问题