Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# - how do I find a key value inside an enum with a property?

Tags:

c#

Given the C# enum:

public enum options: byte
{
    yes = 0,
    no = 22,
    maybe = 62,
    foscho = 42
}

How do you retrieve the String 'maybe' if given the byte 62?

like image 203
yesman Avatar asked Jan 28 '26 16:01

yesman


1 Answers

You can cast it to enum and retreive by ToString():

var result = ((options)62).ToString();