Here's an example:
public void DoSomething(String param1, String param2)
{
if (param1 == null) throw new ArgumentNullException("param1");
if (param2 == null) throw new ArgumentNullException("param2");
}
2 different reasons for an ArgumentNullException. MSDNs String.Format Example shows 2 different reasons for the FormatException
. So, is it done this way:
/// <exception cref="ArgumentNullException">
/// <paramref name="param1"/> is null.
/// </exception>
/// <exception cref="ArgumentNullException">
/// <paramref name="param2"/> is null.
/// </exception>
or some other way?
/// <exception cref="ArgumentNullException">
/// Some other way to show the 2 reasons with an "-or-" between them.
/// </exception>
XML comment sections cannot be nested, because content cannot contain the value "-->".
To insert XML comments for a code element Do one of the following: Type /// in C#, or ''' in Visual Basic.
The cref attribute in an XML documentation tag means "code reference." It specifies that the inner text of the tag is a code element, such as a type, method, or property.
If you think each of the rows of the docs as being one <exception cref=...> </exception>
, then logically the correct way to do it is using your second alternative:
/// <exception cref="ArgumentNullException">
/// <p><paramref name="param1"/> is null. </p>
/// <p>- or - </p>
/// <p><paramref name="param2"/> is null. </p>
/// </exception>
You can use 'p' elements to denote the lines.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With