给定以下这个方法:
/// <summary>
/// Given a <see cref="T1"/>, return a <see cref="T2"/>.
/// </summary>
public T2 ExampleMethod(T1 t1)
{
// omitted
}
我能写出这样的注释,以便于Visual Studio能正确地显示它吗?比如说,如果T1是一个“int”,而T2是一个“string”。或者说,我只能让T1和T2在注释中出现吗?
换句话说,在Visual Studio中有没有什么方法可以使这个方法的工具提示显示实际的类型名称?
编辑:似乎我没有解释清楚我真正感兴趣的内容。
假设我有一个名为Widget的类。假设我有一个像上面那样的方法。
然后,当我执行
Widget<int,string> myExample = new Widget<int,string>();
myExample.ExampleMethod(... ); // HERE - if I mouse over the method
// I get a tooltip. Is there something I can do to the comment in my
// example method above that will allow me to say
// "Given a System.Int32, return a System.String"?
编辑2: 刚刚有人在这里发表了评论,但是他们的评论已被删除。他们建议我使用
///Given a <see cref="T1"/>, return a <see cref="T2"/>.
这是我现在使用的。这很好。我的问题已经第三次用不同的措辞提出了,那就是Visual Studio是否聪明到可以从构造函数中推断出T1和T2是什么?我可以从方法签名中找出T1和T2是什么,而我想也许Visual Studio也可以做到,并在注释中支持此功能。
我的直觉是不行,但这就是我问的问题。