1

Can anybody tell me how to get this working?

 /// <summary>
 /// I want to write: List<T>
 /// </summary>

Any time I use '<' or '>' VS gives up on me... <c> or <code> will not do the trick.

canton7
  • 37,633
  • 3
  • 64
  • 77
user947737
  • 326
  • 2
  • 11
  • Does this answer your question? https://stackoverflow.com/questions/532166/how-to-reference-generic-classes-and-methods-in-xml-documentation – Matthew Mar 04 '20 at 15:01
  • 1
    @Matthew That's specifically about ``, and this question is not – canton7 Mar 04 '20 at 15:03
  • 3
    So far you're getting a couple different approaches, and both will work for the example you've given.. but IMO, the `` makes more sense if you're actually wanting to reference a particular class. Of course if you just want a literal `<` or `>`, then the `<` and `>` approach is pretty much the only option (eg. if you wanted to say something like "Checks if a > b"). – Broots Waymb Mar 04 '20 at 15:11

2 Answers2

5

Try this:

/// <summary>
/// I want to write: <see cref="System.Collections.Generic.List{T}"/>
/// </summary>
mm8
  • 163,881
  • 10
  • 57
  • 88
  • This extends Sean's answer – user947737 Mar 04 '20 at 15:15
  • 2
    @user947737: Not really. This includes an actual type reference in the comment instead of a random string. – mm8 Mar 04 '20 at 15:16
  • 1
    @user947737 - I disagree. It's a totally different approach and deserves to be a separate answer. They address different concerns and this is the appropriate approach IMO, given the situation in your question. – Broots Waymb Mar 04 '20 at 15:16
  • @both: Sean answered my question, this is added value - the extension is to my knowledge! – user947737 Mar 04 '20 at 15:22
  • IMHO, In this particular case, this is a better answer. For a random `<` or `>` (or any other xml-breaking char for that matter), use xml entities as in Sean's answer. – Zohar Peled Mar 04 '20 at 15:36
4

You can use regular xml escaping:

 /// <summary>
 /// I want to write: List&lt;T&gt;
 /// </summary>
Sean
  • 60,939
  • 11
  • 97
  • 136