Kevin
Kevin

Reputation: 3623

Defining C# enums with descriptions

What would the folowing VB.NET enum definition look like in C#?

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

Upvotes: 7

Views: 828

Answers (7)

Younes
Younes

Reputation: 4823

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

Upvotes: 0

AnthonyWJones
AnthonyWJones

Reputation: 189437

Like this:-

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

Upvotes: 0

Yuriy Zanichkovskyy
Yuriy Zanichkovskyy

Reputation: 1699

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

Upvotes: 0

Ozgur Ozcitak
Ozgur Ozcitak

Reputation: 10619

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

Upvotes: 4

asbestossupply
asbestossupply

Reputation: 11909

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

Upvotes: 3

JaredPar
JaredPar

Reputation: 754565

Try the following

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

Upvotes: 4

dtb
dtb

Reputation: 217253

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

Upvotes: 9

Related Questions