Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to automatically generate comments in Visual Studio 2010 and C#?

From Eclipse I'm used that when I start typing a comment for a class or method, the parameters, return types and exceptions are autogenerated. But in VisualStudio 2010 I can't find something like this. Any hints how to achieve that?

like image 421
RoflcoptrException Avatar asked Mar 14 '11 16:03

RoflcoptrException


People also ask

How do I auto generate comments in Visual Studio?

Do one of the following: Type /// in C#, or ''' in Visual Basic. From the Edit menu, choose IntelliSense > Insert Comment. From the right-click or context menu on or just above the code element, choose Snippet > Insert Comment.

How do you comment multiple lines in C#?

Multi-line comments start with /* and ends with */ . Any text between /* and */ will be ignored by C#.

How do you make a comment in C#?

A comment is preceded by an double forward slash. The code of line after the double forward slash is simply ignored by the compiler. To code a comment, type an double forward slash followed by the comment. You can use this technique to add a comment on its own line or to add a comment after the code on a line.


2 Answers

The only way I know to do this is on the line right above your method just type "///" and it will generate a comment template based on the method.

like image 167
AridTag Avatar answered Oct 20 '22 19:10

AridTag


GhostDoc is a free extension that will do this. Just hit (by default) Ctrl+D anywhere within a method, and it will add XML Documentation comments with defaults filled in (though they typically should be modified/expanded).

like image 26
Reed Copsey Avatar answered Oct 20 '22 19:10

Reed Copsey