Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to refer to enum constants in c# xml docs

Tags:

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.

like image 960
Bruno Martinez Avatar asked Apr 30 '10 14:04

Bruno Martinez


People also ask

Is enum constant in C?

In C programming, an enumeration type (also called enum) is a data type that consists of integral constants. To define enums, the enum keyword is used. enum flag {const1, const2, ..., constN}; By default, const1 is 0, const2 is 1 and so on.

How are enumeration variables declared in C?

Enumeration is a user defined datatype in C language. It is used to assign names to the integral constants which makes a program easy to read and maintain. The keyword “enum” is used to declare an enumeration.

Can we define constants in enum?

The enum type, introduced in Java 5, is a special data type that represents a group of constants. Using enums, we can define and use our constants in the way of type safety. It brings compile-time checking to the constants.


2 Answers

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)

like image 169
João Angelo Avatar answered Sep 28 '22 19:09

João Angelo


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.

like image 20
RobSiklos Avatar answered Sep 28 '22 21:09

RobSiklos