typeparam

This element is used to describe generic parameters on generic types and methods.

Syntax

This top-level element is valid on generic types and generic methods to describe each generic type parameter. typeParamName is the name of the generic type parameter being referenced.

 
<typeparam name="typeParamName">Type parameter description</typeparam>

Remarks

There should be one typeparam element for each generic type parameter in the class or method declaration. The description will be used as the display text for the parameter in IntelliSense and the Object Browser.

Examples

 
/// <summary>
/// This class is used to demonstrate the various XML comments elements
/// related to generics.  It serves no useful purpose.
/// </summary>
/// <typeparam name="T1">This is the first generic argument.</typeparam>
/// <typeparam name="T2">This is the second generic argument constrained to
/// be or derive from <see cref="EventArgs"/>.</typeparam>
/// <conceptualLink target="163cae15-9020-4095-9b9c-da134b5b496c" />
public class GenericClass<T1, T2> where T2 : EventArgs
{
    /// <summary>
    /// This is a property that gets or sets an instance of the type specified
    /// by the generic type argument <typeparamref name="T1"/>.
    /// </summary>
    /// <conceptualLink target="073a5ae1-828f-4bab-b0cb-438cefb5e9fb" />
    public T1 Property { get; set; }

    /// <summary>
    /// This is a method with an argument.
    /// </summary>
    /// <param name="argument"> This is an argument of the type specified by
    /// the generic type argument <typeparamref name="T1"/>.</param>
    /// <conceptualLink target="073a5ae1-828f-4bab-b0cb-438cefb5e9fb" />
    public void Method(T1 argument)
    {
    }

    /// <summary>
    /// This is a generic method that takes two other generic types
    /// </summary>
    /// <typeparam name="T3">This is a generic type argument for the method
    /// argument.</typeparam>
    /// <typeparam name="T4">This is a generic type argument for the return
    /// value.</typeparam>
    /// <param name="argument">This is an argument of the type specified by
    /// the generic type argument <typeparamref name="T3"/>.</param>
    /// <returns>The default value of the type specified by the generic type
    /// argument <typeparamref name="T4"/>.</returns>
    /// <conceptualLink target="163cae15-9020-4095-9b9c-da134b5b496c" />
    /// <conceptualLink target="073a5ae1-828f-4bab-b0cb-438cefb5e9fb" />
    public T4 GenericMethod<T3, T4>(T3 argument)
    {
        return default(T4);
    }

    /// <summary>
    /// This is an event that takes a generic argument.
    /// </summary>
    /// <remarks>The <see cref="Delegate">delegate</see> for this event is
    /// <see cref="EventHandler{T}"/> bound to the type specified by the
    /// generic type argument <typeparamref name="T2"/>.
    /// </remarks>
    /// <conceptualLink target="073a5ae1-828f-4bab-b0cb-438cefb5e9fb" />
    public event EventHandler<T2> SomethingHappened;

    /// <summary>
    /// This is a protected virtual method used to raise the
    /// <see cref="SomethingHappened"/> event.
    /// </summary>
    /// <param name="e">Arguments for the event of the type specified by
    /// the generic type argument <typeparamref name="T2"/>.</param>
    /// <conceptualLink target="073a5ae1-828f-4bab-b0cb-438cefb5e9fb" />
    protected virtual void OnSomethingHappened(T2 e)
    {
        var handler = SomethingHappened;

        if(handler != null)
            handler(this, e);
    }
}

See Also