加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

XML注释 – 如何评论异常的多个原因?

发布时间:2020-12-16 07:50:04 所属栏目:百科 来源:网络整理
导读:这是一个例子: public void DoSomething(String param1,String param2){ if (param1 == null) throw new ArgumentNullException("param1"); if (param2 == null) throw new ArgumentNullException("param2");} ArgumentNullException的2个不同原因. MSDN St
这是一个例子:
public void DoSomething(String param1,String param2)
{
    if (param1 == null) throw new ArgumentNullException("param1");
    if (param2 == null) throw new ArgumentNullException("param2");
}

ArgumentNullException的2个不同原因. MSDN String.Format Example显示了FormatException的两个不同原因.那么,它是这样做的:

/// <exception cref="ArgumentNullException">
///     <paramref name="param1"/> is null.
/// </exception>
/// <exception cref="ArgumentNullException">
///     <paramref name="param2"/> is null.
/// </exception>

还是其他一些方式?

/// <exception cref="ArgumentNullException">
///     Some other way to show the 2 reasons with an "-or-" between them.
/// </exception>
如果您认为文档的每一行都是一个< exception cref = ...> < / exception>,然后逻辑上正确的方法是使用你的第二个选择:
/// <exception cref="ArgumentNullException">
///     <p><paramref name="param1"/> is null. </p>
///     <p>- or - </p>
///     <p><paramref name="param2"/> is null. </p>
/// </exception>

您可以使用’p’元素来表示线条.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读