标签: microsoft-documentation

代码文档,从常量中获取值

是否有可能有一个常数

 public const string MyString = "myValue"
Run Code Online (Sandbox Code Playgroud)

在 xml 注释中获取其值“myValue”?我对此感兴趣,以生成招摇文档。

    /// <summary>
    /// Creates a new resource.
    /// </summary>
    /// <param name="request">The request object.</param>
    /// <returns code="200">The id of the new resource.</returns>
    /// <response code="400">
    /// <see cref="Errors.BadRequestCodes.MyString"/><para/>
    /// </response>
Run Code Online (Sandbox Code Playgroud)

这是记录端点的示例。在 swagger ui 中,我实际上看到的是“Errors.BadRequestCodes.MyString”,而不是在 400 状态代码部分看到消息“myValue”。有什么方法可以实现这一点吗?

c# xml-documentation microsoft-documentation

6
推荐指数
1
解决办法
793
查看次数

派生类可以重新定义具有不同签名的函数的虚函数吗?

Microsoft文档页面之一中给出了一些奇怪的示例,该示例页面由两个类组成,一个是基类,另一个是派生类。基类具有以下虚拟函数成员:

virtual void setEars(string type)      // virtual function
{
    _earType = type;
}
Run Code Online (Sandbox Code Playgroud)

另一个在派生类中定义,如注释中所述,它重新定义了虚函数:

// virtual function redefined
void setEars(string length, string type)
{
    _earLength = length;
    _earType = type;
}
Run Code Online (Sandbox Code Playgroud)

这两个具有不同的签名,我还从未听说过您是否真的可以用另一个签名的函数重新定义虚拟函数。我编译了此示例,可以发现这两个示例之间的所有替代行为。样本只是误导还是我遗漏了一些东西?

c++ microsoft-documentation

3
推荐指数
1
解决办法
60
查看次数