How to get Enum object by value in C#? -


i encountered case when needed enum object value (to saved via ef codefirst), , here enum:

public enum shipmentstatus {   new = 0,   shipped = 1,   canceled = 2 } 

so needed shipmentstatus.shipped object value 1.

so how accomplish that?

why not use build in feature?

shipmentstatus shipped = (shipmentstatus)system.enum.getvalues(typeof(shipmentstatus)).getvalue(1); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -