66

As I know, in a XML comment for a C# type/method, it is possible to reference a generic type in a tag like so:

///<see cref="name.space.typename&lt;T&rt;(paramtype)">

But I think, there was another syntax, which is less clumsy? Something, to get rid of those html entities '<'? I cannot find it right now. Can somebody help?

user492238
  • 4,094
  • 1
  • 20
  • 26

2 Answers2

81

Here's a citation of a no longer available, good article on documentation:

The compiler team decided to improve this by allowing an alternate syntax to refer to generic types and methods in doc comments. Specifically, instead of using the open and close angle-brackets it’s legal to use the open and close curly braces. The example above would then become:

class Program
{
    /// <summary>
    /// DoSomething takes a <see cref="List{T}"/>
    /// </summary>
    void DoSomething(List<int> al) { }
}

So, in your case:

///<see cref="name.space.typename{T}(paramtype)"/>

Here are a couple of newer references from Microsoft:

Vandrey
  • 531
  • 1
  • 8
  • 23
Metro Smurf
  • 37,266
  • 20
  • 108
  • 140
  • 7
    Yes, but the curly braces do show up in Visual Studio (2005..2012) Intellisense as `{T}`, not as ``. – Pierre Arnaud May 15 '13 at 03:29
  • 3
    @PierreArnaud - FWIW, the new Roslyn-based language analysis in Visual Studio 2015 now correctly displays the reference to List as 'List' instead of 'List{T}' in the tooltip :) – Theo Yaung Feb 25 '15 at 05:20
9

Use curly brackets:

///<see cref="name.space.typename{T}(paramtype)">
John Saunders
  • 160,644
  • 26
  • 247
  • 397