C#、XmlDoc:如何引用方法重载
如果我有这两种方法
public Foo Get(string bar) { ... }
public Foo Get(int bar) { ... }
并在不同的方法上编写这段 xml 文档,
/// <summary>
/// Has a close relation to the <see cref="Get"/> methods.
/// </summary>
我会在 Get
下看到一个蓝色波浪线,表示它是一个不明确的引用“Get”。 这是真的,但我希望它引用两者。 这样做的正确方法是什么? 或者我应该只引用单个方法重载?
If I have these two methods
public Foo Get(string bar) { ... }
public Foo Get(int bar) { ... }
And write this piece of xml documentation on a different method
/// <summary>
/// Has a close relation to the <see cref="Get"/> methods.
/// </summary>
I get a blue squiggly under Get
, saying that it is an Ambiguous reference 'Get'. which is true, but I want it to reference both. What is the correct way of doing this? Or should am I only supposed to reference a single method overload?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下
,您可能需要完整的类型名称,但只要您放入第一个括号,智能感知就会有所帮助。
希望有所帮助,
丹
Try
You may need full typenames but intellisense should help as soon as you put first bracket in.
Hope that helps,
Dan
这是这个老问题的更新答案。 我不确定这何时生效,因为没有太多文档。 如果您为
cref
属性添加"o:..."
前缀,例如在"o:myMethod()"
中,它将链接到重载部分并覆盖该方法的所有重载。 使用 Daniel Elliott 的答案示例:这还将删除 Intellisense / Resharper 关于不明确引用的警告。
Here's an updated answer to this old question. I'm not sure when this became valid because there isn't much documentation out there. If you prefix a
cref
attribute with"o:..."
such as in"o:myMethod()"
it will link to the overload section and cover all of the overloads of that method. Using Daniel Elliott's answer's example:This will also remove warnings from Intellisense / Resharper about ambiguous references.