繁体   English   中英

C#:如何在xml注释中引用默认(T)和构造函数

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

我在下面的答案中看到了这门课程。 在那里,我可以参考例如Value<see cref="Value"/>和类本身具有<see cref="GenericEventArgs{T}"/>

  1. 我怎样才能参考默认值(T)? 它甚至可能吗?
  2. 我怎样才能参考构造函数?

/// <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; }
}

.net文档本身将其称为:“值参数类型的默认值”。

请参阅Dictionary.TryGetValue的文档

不,我认为这是不可能的。 由于类在运行时使用正确的类型进行JIT,因此文档与所使用的实际类型无关。 如果使用类约束,则可以使用“null”替换default。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM