Silverten
Silverten

Reputation: 121

Is there any way to set XML comment to local variables?

Simple: Is there any way to set XML comment to local variables in Visual Studio? Specially looking for the following (which will not work in any version of VS)..

Such as:

/// <summary>
/// Perform editing of multiple HexCells in the HexGrid.
/// </summary>
void EditCells(HexCell center)
{
    /// <summary>
    /// This is the horizontal center of the a cell that I'm working with.
    /// </summary>
    var centerX = center.coordinates.X;

    /// <summary>
    /// This is the vertical center of the a cell that I'm working with.
    /// </summary>
    var centerZ = center.coordinates.Z;

    ...

Is there any way of doing this?

Upvotes: 9

Views: 3049

Answers (1)

Yeldar Kurmangaliyev
Yeldar Kurmangaliyev

Reputation: 34189

No, there is no sense in XML-documenting your local variables.

XML documentation provides information for those who use your assembly / class / method. It is not supposed to be read through code. They cannot access local variables and therefore they won't be able to access this documentation.

If you want to make a comment for those who read or maintain your code, then you can just use simple comments.

Upvotes: 5

Related Questions