C# - 如何从隐藏方法(新关键字)继承文档
有没有办法不隐藏儿童类中原始方法的文档?例如;
public class Parent
{
/// <summary>
/// Boo!!!
/// </summary>
public void Foo()
{
// ... code here
}
}
public class Child : Parent
{
// inheritdoc doesn't work here
/// <inheritdoc/>
public new void Foo()
{
base.Foo();
// ... additional logic here
}
}
Is there a way not to hide the documentation of the original method in the child class? For example;
public class Parent
{
/// <summary>
/// Boo!!!
/// </summary>
public void Foo()
{
// ... code here
}
}
public class Child : Parent
{
// inheritdoc doesn't work here
/// <inheritdoc/>
public new void Foo()
{
base.Foo();
// ... additional logic here
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如穆罕默德(Muhammad)刚刚说的那样:通过宣布使用
new
关键字的方法,您基本上创建了一个新方法签名,该签名以任何方式与旧方法无关。虚拟
方法但是覆盖
旧方法而不是介绍。因此,覆盖方法将继承其文档。As Muhammad just said: By declaring a method with the
new
keyword, you basically create a new method signature, that is not related to the old method in any way. Avirtual
method howeveroverrides
the old method instead of covering it up. Therefore overriding a method will inherit its documentation.