如何将Intellisense描述添加到枚举成员c#

时间:2013-10-23 20:40:11

标签: c# enums

我有这个枚举:

/// <summary>
/// Accoun types enumeration
/// </summary>
public enum AcoountTypeTransaction
{
    [Description("Account type debit")]
    Debit = 0,
    [Description("Account type Credit")]
    Credit = 1
} 

我想展示我的intellisense的描述,这只是一个样本,我有许多必须解释的枚举。有一种方法可以做到这一点

1 个答案:

答案 0 :(得分:18)

使用XML document comments的方式与枚举声明本身的方式相同。

/// <summary>
/// Account types enumeration
/// </summary>
public enum AcoountTypeTransaction
{
    /// <summary>
    /// This is the Debug  constant.
    /// </summary>
    [Description("Account type debit")]
    Debit = 0,
    /// <summary>
    /// This is the Credit constant.
    /// </summary>
    [Description("Account type Credit")]
    Credit = 1
} 

Result