How to refer to enum constants in c# xml docs

2019-04-19 08:56发布

问题:

I want to document the default value of an enum typed field:

/// <summary>
/// The default value is <see cref="Orientation.Horizontal" />.
/// </summary>
public Orientation BoxOrientation;

The compiler warns that it couldn't resolve the reference. Prefixing F: or M: silences the compiler, but E: also does, so I'm unsure what prefix is correct.

回答1:

The prefixes F, M and E are all valid and probably the reason that the compiler warning disappears.

You should however use the F that refers to fields. For more information on how Visual Studio generates documentation identifiers see:

Processing the XML File (C# Programming Guide)



回答2:

I don't think you should need the prefix - probably you need to add a "using" to the namespace where the Orientation type is defined.