views:

1211

answers:

2

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? 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. How could I make a see cref thing for that?

+9  A: 
/// <summary>Uses a <see cref="FancyClass{T}" /> instance.</summary>

BTW, it was present in the MSDN documentation of .Net Framework 2.0 and 3.0, but it disapeared in the version 3.5

Think Before Coding
what about a spesific instance of T? like string? Maybe not possible?
Svish
what do you mean? You can't declare a specific version, so you can't refer to it either.
Lasse V. Karlsen
If a method for example only returns List<string> for example. But not important :)
Svish
Yes I was wondering also... resharpers squiggles when writing FancyClass{string} but not when writing FancyClass{String}...
Think Before Coding
That seems to be correct! Thank you TBC :)
Svish
+11  A: 

To reference the method:

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