Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add documentation tooltip to classes, methods, properties, etc. in C#?

Not sure if I'm even calling this right but I wanted to start adding some documentation to my classes, methods, properties, etc. I know this is probably super obvious but I never really learned it. I'm not sure where to start.

Just to clarify whenever you roll over a class (or method, property, etc.) it shows a tooltip in Visual Studio with some documentation on that specific method.

class Microsoft.Phone.BackgroundAudio.BackgroundAudioPlayer
Provides background access to audio playback functionality such as play, pause, fast-forward, and rewind.

What is that called and how can I implement this in my C# application?

like image 860
Edward Avatar asked Dec 01 '11 20:12

Edward


People also ask

How to create ToolTip in asp net c#?

<scriptsrc="http://code.jquery.com/jquery-1.8.2.js"type="text/javascript"></script>

What is ToolTip control in C#?

In Windows Forms, the ToolTip represents a tiny pop-up box which appears when you place your pointer or cursor on the control and the purpose of this control is it provides a brief description about the control present in the windows form.

How do I show tooltips in Visual Studio?

Ctrl+Space opens the IntelliSense dropdown list, but pressing Ctrl+Shift+Space inside the brackets of the method call gets the tooltip.


2 Answers

You can use /// or GhostDoc

Edit:

In first case you'll get

/// <summary> ///  /// </summary> class A {     /// <summary>     ///      /// </summary>     public A() { }      /// <summary>     ///      /// </summary>     public int Property { get; set; }      /// <summary>     ///      /// </summary>     /// <param name="obj"></param>     public void Method(object obj) { } } 

In second

/// <summary> ///  /// </summary> class B {      /// <summary>     /// Initializes a new instance of the <see cref="B"/> class.     /// </summary>     public B() { }      /// <summary>     /// Gets or sets the property.     /// </summary>     /// <value>     /// The property.     /// </value>     public int Property { get; set; }      /// <summary>     /// Methods the specified obj.     /// </summary>     /// <param name="obj">The obj.</param>     public void Method(object obj) { } } 
like image 83
Alex Kovanev Avatar answered Sep 25 '22 09:09

Alex Kovanev


Just above your class, method or property, type /// then press return. This will generate the documentation template for you.

Forgot to answer the other part of your question: this is known as XML Documentation Comments and there is a substantial amount of information about this in MSDN.

like image 31
competent_tech Avatar answered Sep 26 '22 09:09

competent_tech