example

Sandcastle XML Comments

Sandcastle XML Comments Guide example

This element is used to define an example for a type or one of its members to show how it is used.

Syntax

This top-level element is valid on all types and members. A description is optional. One or more code elements are typically included to show the example code. More descriptive text can be included between the code elements as needed.

<example>
Optional code description

<code language="cs">
/// Example code
</code>

</example>
Example
/// <summary>
/// This returns a random number
/// </summary>
/// <returns>A random number using <see cref="SampleNumber"/> as the seed.</returns>
/// <example>
/// The following example demonstrates the use of this method.
/// 
/// <code language="cs">
/// // Get a new random number
/// SampleClass sc = new SampleClass(10);
/// 
/// int random = sc.GetRandomNumber();
///
/// Console.WriteLine("Random value: {0}", random);
/// </code>
/// 
/// <code language="vb">
/// ' Get a new random number
/// Dim sc As SampleClass = New SampleClass(10)
/// 
/// Dim random As Integer = sc.GetRandomNumber()
///
/// Console.WriteLine("Random value: {0}", random)
/// </code>
/// </example>
/// <conceptualLink target="1abd1992-e3d0-45b4-b43d-91fcfc5e5574" />
/// <conceptualLink target="1bef716a-235b-4d96-a23e-f43b8dcf9abd" />
public int GetRandomNumber()
{
    return new Random(this.SampleNumber).Next();
}
See Also

Reference

Other Resources