我有 2 个私有常量和一个公共方法:
private const byte _minAge = 24;
private const byte _maxAge = 29;
public bool IsInAgeRange() { ... }
我正在添加 XML 文档,并且希望我的代码的用户能够在 IntelliSense 中阅读此文档:Checks whether the age is within the allowed range (between 24 and 29).
我的问题是:
有没有办法将我的常量呈现到我的 XML 文档中?
我提出的替代方案是:
- 只需在文档中写入 24 和 29(缺乏对实际值的依赖)
- 公开常量并添加
<see cref="MinAge">
and <see cref="MaxAge">
(减少封装并使文档的信息量减少)
向包含该值的每个常量添加摘要,然后参考这些注释:
/// <summary>24</summary>
private const byte _minAge = 24;
/// <summary>29</summary>
private const byte _maxAge = 29;
/// <summary>Checks whether the age is within the allowed range (between <inheritdoc cref="_minAge"/> and <inheritdoc cref="_maxAge"/>).</summary>
public bool IsInAgeRange() { ... }
我知道这仍然是重复的,但是这样您就可以将常量注释保留在常量附近,即使常量完全在另一个文件中定义也是如此。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)