在C#Visual Studio中为Enums提供描述性帮助上下文?

时间:2015-05-10 01:48:10

标签: c# visual-studio autocomplete ide

是否可以在代码下拉列表中为每个单独的枚举显示帮助上下文? (即控制空间?)

e.g。

public enum Moods
{
    Depressed = 1,  ///On Rainy Days use this
    BlownAway = 2, ///On Stormy nights use this
    Ferengi = 3  //Use this for Profit and glory
}

以及稍后在代码中输入特定的枚举,当我们输入代码时,代码完成下拉列表中会显示该注释:Moods.

1 个答案:

答案 0 :(得分:3)

对于智能感知描述,请使用<summary>标记,如:

/// <summary>
/// Various moods
/// </summary>
public enum Moods
{
    /// <summary>
    /// On Rainy Days use this
    /// </summary>
    Depressed = 1,  
    /// <summary>
    /// On Stormy nights use this
    /// </summary>
    BlownAway = 2, 
    /// <summary>
    /// Use this for Profit and glory
    /// </summary>
    Ferengi = 3  
}