Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a standard (like phpdoc or python's docstring) for commenting C# code?

Tags:

comments

c#

Is there a standard convention (like phpdoc or python's docstring) for commenting C# code so that class documentation can be automatically generated from the source code?

like image 625
Mark Biek Avatar asked Aug 29 '08 15:08

Mark Biek


People also ask

Are docstrings same as comments in Python?

A python comment may be a single line comment or a multiline comment written using single line comments or multiline string constants. Document strings or docstrings are also multiline string constants in python but they have very specific properties unlike python comment.

Is docstring same as as a comment?

A quick recap on comments vs docstrings: Use comments to explain how code works. Comments are great for leaving notes for people working on your program. Docstrings provide documentation about functions, classes, and modules. Use docstrings to teach other developers how to use your program.

Is a docstring a comment?

In programming, a docstring is a string literal specified in source code that is used, like a comment, to document a specific segment of code.


1 Answers

You can use XML style comments, and use tools to pull those comments out into API documentation.

Here is an example of the comment style:

/// <summary> /// Authenticates a user based on a username and password. /// </summary> /// <param name="username">The username.</param> /// <param name="password">The password.</param> /// <returns> /// True, if authentication is successful, otherwise False. /// </returns> /// <remarks> /// For use with local systems /// </remarks> public override bool Authenticate(string username, string password) 

Some items to facilitate this are:

GhostDoc, which give a single shortcut key to automatically generate comments for a class or method. Sandcastle, which generates MSDN style documentation from XML comments.

like image 62
Forgotten Semicolon Avatar answered Oct 11 '22 12:10

Forgotten Semicolon