We help IT Professionals succeed at work.

How to create XML comments for local variables


I'm using MS Visual Studio 2008. The XML comments for classes, methods and properties are very useful and I often rely on the possibility to move my cursor above an identifier and see explanation of what it is. However, I'm missing this functionality for local variables. I can see just their type, name and if they parameter or local variable. Is there any way to get explanatory comments for local variables as well?
Watch Question

Shot in the dark, but doing

/// <summary>
/// Start time of the event.
/// </summary>
public DateTime startTime;

seems to do what you want.
Senior Software Engineer
Top Expert 2009
I do not think is possible, the compiler will ignore your comments because it is not allowed to write XML tags within functions, check:

Hi! Since it is only a local variable, then you may use the double slash (//) comment or the nested (/* */).