gpt4 book ai didi

c# - 我可以在构造函数注释中引用属性注释吗?

转载 作者:数据小太阳 更新时间:2023-10-29 02:48:56 25 4
gpt4 key购买 nike

如果我的类有一个通过构造函数分配的注释公共(public)属性,我可以从具有相同名称的构造函数参数的描述中引用它的描述吗?

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;
}
}

最佳答案

您不能包含描述,但您可以使用 <see> 链接到属性文档标签。例如:

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

顺便说一句,我强烈建议您遵循 .NET 命名约定,其中公共(public)成员以大写字母开头。

关于c# - 我可以在构造函数注释中引用属性注释吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34149589/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com