views:

403

answers:

2

I have this class you see below in the answer. There I can refer to for example the Value with <see cref="Value"/>, and the class itself with <see cref="GenericEventArgs{T}"/>.

  1. How can I refer to default(T)? Is it even possible?
  2. How can I refer to the constructors?


/// <summary>
/// A simple <see cref="EventArgs"/> class that can contain a value.
/// </summary>
/// <typeparam name="T">Type of <see cref="Value"/>.</typeparam>
public class GenericEventArgs<T> : EventArgs
{
    /// <summary>
    /// Instantiates a <see cref="GenericEventArgs{T}"/> with 
    /// <see cref="default"/> default as Value.
    /// </summary>
    public GenericEventArgs()
        : this(default(T)) {}


    /// <summary>
    /// Instantiates a <see cref="GenericEventArgs{T}"/>
    /// </summary>
    /// <param name="value"></param>
    public GenericEventArgs(T value)
    {
        Value = value;
    }


    /// <summary>
    /// The value.
    /// </summary>
    public T Value { get; private set; }
}
A: 

No, I think it is not possible. Since the class is JITed at runtime with the correct types, the documentation is independent of the actual types used. If you use a class constraint, you can substitute default with "null".

Lucero
+1  A: 

The .net documentation itself referes to this as: "the default value for the type of the value parameter".

See the Documentation of Dictionary.TryGetValue

Fionn