Svish Svish - 25 days ago 9
C# Question

How to reference generic classes and methods in xml documentation

When writing xml documentation you can use

<see cref="something">something</see>
, which works of course. But how do you reference a class or a method with generic types?

public class FancyClass<T>
{
public string FancyMethod<K>(T value) { return "something fancy"; }
}


If I was going to write xml documentation somewhere, how would I reference the fancy class? how can I reference a
FancyClass<string>
? What about the method?

For example in a different class I wanted to let the user know that I will return an instance of
FancyClass<int>
. How could I make a see cref thing for that?

Answer

To reference the method:

/// <see cref="FancyClass{T}.FancyMethod{K}(T)"/> for more information.
Comments