问题描述
是否可以从与您为其编写摘要的方法不同的方法中引用参数,如果是,则语法是什么.
Is it possible to reference a parameter from a different method than the one you are writing a summary for, and if so what is the syntax.
我了解<paramref name="..."/>
,但是我不知道如何通过其他方法进行引用.
I know about <paramref name="..."/>
but I don't know how to reference from a different method.
一个简单幽默的例子,以防万一我不清楚:
Simple humorous example in case I'm not making myself clear:
/// <summary>
/// Does magical Foo things!
/// </summary>
/// <param name="magic">Magic Toggle!</param>
public void Foo(bool magic)
{
//...
}
/// <summary>
/// Does Bar things. More down to earth, no <paramref name="Foo(bool).magic"/> involved!
/// </summary>
public void Bar()
{
//...
}
(显然以上并不是一个很好的用例,仅用于说明目的.)
(Obviously the above is not a great use case, it's just for illustratory purposes.)
推荐答案
没有为此推荐标签.
我怀疑没有推荐标签的原因是因为本文档的主要用例是生成的MSDN页面样式的文档,该文档没有利用到其他方法的特定参数的链接.也就是说,这不是规格,只是建议.您编写的任何有效XML都将最终出现在输出XML文件中,因此,如果您有一个自定义的文档生成器,可以利用此生成器,那么没有什么会阻止您添加"custom"标签来完成所需的工作.
I suspect the reason why there is no recommended tag is because the primary use-case of this documentation is generated documentation in the style of the MSDN pages which doesn't make use of links to specific parameters of other methods. That said, its not a spec, just a recommendation. any valid XML you write will end up in the output XML file, so if you have a custom documentation generator which would make use of this there is nothing stopping you from adding "custom" tags that do whatever it is you need.
我个人会做这样的事情:
Personally I'd just do something like this:
interface IFoo
{
void Foo(object otherParam);
/// <summary>Documentation for this method.</summary>
/// <returns>The object passed as the otherParam argument of
/// the <see cref="Foo" /> method.</returns>
object Bar();
}
这篇关于如何引用其他方法的参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!