exception

This element is used to list exceptions that can be thrown by a type's member.

Syntax

This top-level element is valid on property, method, event, operator, and type conversion members. exceptionType is the name of the exception type that can be thrown.

 
<exception cref="exceptionType">description</exception>

Remarks

There should be one exception element for each exception type that can be thrown. The description will be used as the display text for the exception in IntelliSense and the Object Browser.

Example

 
/// <summary>
/// This method processes text
/// </summary>
/// <param name="text">The text to process</param>
/// <exception cref="ArgumentNullException">This is thrown if the <paramref name="text"/>
/// parameter is null.</exception>
/// <exception cref="ArgumentException">This is thrown if the <paramref name="text"/>
/// parameter is an empty string.</exception>
/// <exception cref="InvalidOperationException">This is thrown because the method
/// is not currently implemented.</exception>
/// <conceptualLink target="bbd1e65d-c87c-4b46-9a1a-259d3c5cd936" />
public void ProcessText(string text)
{
    if(text == null)
        throw new ArgumentNullException("text cannot be null");

    if(text.Trim().Length == 0)
        throw new ArgumentException("text cannot be an empty string");

    throw new InvalidOperationException();
}

See Also

Reference

Other Resources