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
Post a Comment