2010-07-22 63 views
26

我該如何評論這個Enum,以避免警告出現?是的,我意識到評論是不必要的,但如果評論很容易,它解決了警告,那麼我想這樣做。如何評論一個公開可見的類型枚舉?

警告顯示:爲公開可見的類型或成員

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

回答

73

喜歡這個 缺少XML註釋:

/// <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 
} 

(是的,這會造成非常繁瑣)

您可能想在評論中使用不同的文字。

順便說一句。你的枚舉實際上應該叫做ComparisonType

+1

Upvoted爲ComparisonType,這是非常重要的! – Lucas 2017-04-04 11:50:48

10

評論每個成員:

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

您可能還需要檢查出GhostDoc,方便評論