使用描述定义C#枚举

时间:2010-01-27 15:53:08

标签: c# vb.net enums

下面的VB.NET枚举定义在C#中会是什么样的?

Public Enum SomeEnum As Integer
    <Description("Name One")> NameOne = 1
End Enum

7 个答案:

答案 0 :(得分:8)

public enum SomeEnum : int
{
    [Description("Name One")] NameOne = 1
}

答案 1 :(得分:4)

public enum SomeEnum: int
{
    [Description("Name One")]
    NameOne = 1,
}

答案 2 :(得分:3)

尝试以下

enum SomeEnum
{
    [Description("Name One")] NameOne = 1
}

答案 3 :(得分:2)

public enum SomeEnum : int
{
[Description("Name One")]
NameOne = 1
}

答案 4 :(得分:0)

public enum SomeEnum 
{
[Description("Name One")]
NameOne = 1
}

答案 5 :(得分:0)

像这样: -

public enum SomeEnum
{
   [Description("Name One")]
   NameOne = 1;
}

答案 6 :(得分:0)

public enum SomeEnum : int 
{ 
    [Description("Name One")] NameOne = 1 
}