Krish
Krish

Reputation: 167

Enums with description and values as Integers

I am creating a dropdown and I need to define an enum with inegerlike this

Public enum Example
{
  [Description("Any")]
  0,
  [Description("1")]
  1,
  [Description("2")]
  2
}

I want to display integers and values also as integers.

It gives syntax or compilation errors. Please help

Upvotes: 0

Views: 98

Answers (1)

Z .
Z .

Reputation: 12837

public enum Example
{
  [Description("Any")]
  Any = 0,
  [Description("1")]
  One = 1,
  [Description("2")]
  Two = 2
}

Upvotes: 2

Related Questions