Tuesday, 15 September 2015

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



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

given c# enum:

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

how retrieve string 'maybe' if given byte 62?

you can cast enum , retreive tostring():

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

c#

No comments:

Post a Comment