是否有可能有一个常数
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”。有什么方法可以实现这一点吗?
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)
这两个具有不同的签名,我还从未听说过您是否真的可以用另一个签名的函数重新定义虚拟函数。我编译了此示例,可以发现这两个示例之间的所有替代行为。样本只是误导还是我遗漏了一些东西?