在指定摘要标记注释时,是否有一种方法可以使用<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
由于
答案 0 :(得分:6)
name
,如下所示:
<param name="FileName" >The filename of the file to be loaded.</param>
您唯一能做的就是为输出文档设置xsl transform。但这对Intellisense没有任何影响。
答案 1 :(得分:1)
您可以使用<remarks></remarks>
标记。不存在可选参数的特殊标记。
答案 2 :(得分:1)
您应该提供省略可选参数的重载:
/// <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)
{
...
}