Monday, May 24, 2010

How to give tooltip to class properties in C# like Intellisence?

In .Net IDE We have Intellisence facility which will give automatically class methods and properties etc when we press dot(.) operator. While moving the mouse pointer on class properties or function names we will get help text about that properties. How can I give the help text to my class properties and functions.

How to give tooltip to class properties in C# like Intellisence?
You use XML comments. Basically, XML comments are tags that you put before methods, classes, etc... We enter these XML comments after a triple backslash.





Here is an example:





///%26lt;summary%26gt;A funtion that does something.%26lt;/summary%26gt;


///%26lt;param name="i"%26gt;I is some int...%26lt;/param%26gt;


///%26lt;param name="input"%26gt;Input is some string...%26lt;/param%26gt;


///%26lt;returns%26gt;Returns an int%26lt;/returns%26gt;


int DoStuff(string input, int i) {


...


}





For more info on XML comments and what tags are available, go here: http://msdn.microsoft.com/library/en-us/...

forsythia

No comments:

Post a Comment