Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I reference property comments in constructor comments?

Tags:

comments

c#

xml

If my class has a commented public property, which is assigned via constructor, can I reference its description from a description of constructor argument with the same name?

public class MyClass
{
    /// <summary>
    /// x description
    /// </summary>
    public int x { get; private set; }
    /// <summary>
    /// y description
    /// </summary>
    public int y { get; private set; }
    /// <summary>
    /// Constructor description
    /// </summary>
    /// <param name="x">How do I reference x description from here?</param>
    /// <param name="y">And y description?</param>
    public MyClass(int x, int y)
    {
        this.x = x;
        this.y = y;
    }
}
like image 776
user2136963 Avatar asked Feb 05 '26 07:02

user2136963


1 Answers

You can't include the description, but you can link to the property documentation with the <see> tag. For example:

<param name="x">The initial value for <see cref="x"/></param>

As an aside, I would strongly urge you to follow .NET naming conventions, where public members start with capital letters.

like image 94
Jon Skeet Avatar answered Feb 06 '26 20:02

Jon Skeet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!