Visual Studio -摘要标签注释-可选参数
本文关键字:注释 参数 Studio Visual 标签 | 更新日期: 2023-09-27 18:07:47
当指定摘要标记注释时,<param>
标记是否有办法注意到参数是可选的,即。客户端可以提供一个值或null,例如:<param name="Mime" optional="true">.
google没有给我提供属性或允许值的集合列表。
/// <summary>
/// Sets data associated with instance
/// </summary>
/// <param name="Key">The key defining the data</param>
/// <param name="Value">The data</param>
/// <param name="Mime">The mime type of the data (optional)</param> <----- Mark as optional
谢谢
不行。被VS识别的唯一属性是name
,像这样:
<param name="FileName" >The filename of the file to be loaded.</param>
您唯一能做的就是为输出文档设置xsl转换。但是这对智能感知没有任何影响。
您应该提供一个省略可选参数的重载:
/// <summary>
/// Sets data associated with the instance using the default media type.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
public void SetData(object key, object value)
{
SetData(key, value, null);
}
/// <summary>
/// Sets data associated with the instance using the specified media type.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
/// <param name="mime">The media type of the data.</param>
public void SetData(object key, object value, string mime)
{
...
}
或者,您可以将参数声明为可选:
/// <summary>
/// Sets data associated with the instance.
/// </summary>
/// <param name="key">The key defining the data.</param>
/// <param name="value">The data.</param>
/// <param name="mime">The media type of the data.</param>
public void SetData(object key, object value, string mime = null)
{
...
}
可以使用<remarks></remarks>
标记。不存在可选参数的特殊标记