Yet Another Tech Blog

Create comments for function in C#/VB.Net


Although you can add comments to function in your own format. But, intellisense of Visual studio supports xml comment for function.


Adding comments to function/sub in .Net languages is not something new. This feature is there since beginning (visual studio 2003).

However manier times I find that developers are not aware of this feature. Many ask this question in .Net forums about how to add

comments to function so that intellisense can pick it.

Article Body

To add comment to function/sub in C# or VB.Net, you just need to place the cursor at the line above start of function

and then in case of C#, simply type forward slash three times (///) and simillarly in case of VB.Net type single quotes three times (''')

it will automatically create defined xml format for comments like one below  


Apart from comment helps you understand purpose, parameter and return type of function while code reading, It is also used by intellisense of

Visual studio when this function is being called from some other part of code. Like one below


As can be seen above, when properly commented function is used it displays summary, parameter information etc. from comment section

This helps a lot to developers who are going to use functions developed by you. They dont have to visit the function code to verify what

is use of each parameter and what functionality covered in function code.

This is very old feature present in .Net and i am not claiming to be original in content. However this would certainly help some rookie :)


The commenting functions in C#/VB is easy and effective and exist since long time.

I just tried here to revisit thie feature to help fresh developers