Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I comment a publicly visible type Enum?

Tags:

comments

c#

enums

How do I comment this Enum so that the warning does not appear? Yes I realize that comments are unnecessary, but if commenting is easy and it resolves the warnings then I'd like to do it.

Warnings that appear: Missing XML comment for publicly visible type or member

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    Equal,
    NotEqual,
    GreaterThan,
    GreaterThanOrEqual,
    LessThan,
    LessThanOrEqual
}
like image 627
Eric Avatar asked Jul 22 '10 14:07

Eric


People also ask

Is enum value type or reference?

Enum is a reference type, but any specific enum type is a value type. In the same way, System. ValueType is a reference type, but all types inheriting from it (other than System. Enum ) are value types.

What is enum method in C#?

Enums in C# The enum keyword in C# declares a list of named integer constants. An enum can be defined in a namespace, structure or class. However, it is better to define it in a namespace so that all the classes can access it.

What is enum in c# net with example?

In C#, an enum (or enumeration type) is used to assign constant names to a group of numeric integer values. It makes constant values more readable, for example, WeekDays. Monday is more readable then number 0 when referring to the day in a week.

Can enums have the same value python?

By definition, the enumeration member values are unique. However, you can create different member names with the same values.


2 Answers

Like this:

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    ///<summary>A == B</summary>
    Equal,
    ///<summary>A != B</summary>
    NotEqual,
    ///<summary>A > B</summary>
    GreaterThan,
    ///<summary>A >= B</summary>
    GreaterThanOrEqual,
    ///<summary>A < B</summary>
    LessThan,
    ///<summary>A <= B</summary>
    LessThanOrEqual
}

(Yes, this can get very tedious)

You may want to use different texts in the comments.

By the way. your enum should actually be called ComparisonType.

like image 188
SLaks Avatar answered Oct 16 '22 17:10

SLaks


Comment each member:

/// <summary>
/// Conditional statements
/// </summary>
public enum ConditionType
{
    /// <summary>
    /// Tests for equality
    /// </summary>
    Equal,
    /// <summary>
    /// Tests for inequality
    /// </summary>
    NotEqual,
    // etc..
}

You may also want to check out GhostDoc for easy commenting

like image 20
Willem van Rumpt Avatar answered Oct 16 '22 16:10

Willem van Rumpt