Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#: How to refer to default(T) and constructors in xml comments

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; }
}
like image 463
Svish Avatar asked Nov 29 '25 21:11

Svish


1 Answers

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

See the Documentation of Dictionary.TryGetValue

like image 152
Fionn Avatar answered Dec 01 '25 11:12

Fionn