How to reference generic classes and methods in xml documentation

Svish picture Svish · Feb 10, 2009 · Viewed 48.2k times · Source

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

Lasse V. Karlsen picture Lasse V. Karlsen · Feb 10, 2009

To reference the method:

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