Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

<exception> (C# Programming Guide)

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

cref = " member"

A reference to an exception that is available from the current compilation environment. The compiler checks that the given exception exists and translates member to the canonical element name in the output XML. member must appear within double quotation marks (" ").

For more information on how to create a cref reference to a generic type, see <see> (C# Programming Guide).


A description of the exception.

The <exception> tag lets you specify which exceptions can be thrown. This tag can be applied to definitions for methods, properties, events, and indexers.

Compile with /doc to process documentation comments to a file.

For more information about exception handling, see Exceptions and Exception Handling (C# Programming Guide).

// compile with: /doc:DocFileName.xml  

/// comment for class 
public class ErrorClass : System.Exception
    // class definition...

/// comment for class 
class TestClass
    /// <exception cref="ErrorClass">Thrown when...</exception>
    public void DoSomething()
        catch (ErrorClass)

Community Additions

© 2015 Microsoft