Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get value from c# enums

Tags:

c#

enums

I have an enum

public enum ProductionStatus {
    Received = 000,
    Validated = 010,
    PlannedAndConverted = 020,
    InProduction = 030,
    QAChecked = 040,
    Delivered = 070,
    RejectedOrCancelled = 100
}

I need to get value by key from this enum, for example when choosing ProductionStatus.Validated it should return 010. How can I do this?

like image 985
Valentin Grins Avatar asked Feb 22 '13 08:02

Valentin Grins


1 Answers

Just to throw another solution in there...

((int)ProductionStatus.Validated).ToString("D3");
like image 128
markoo Avatar answered Nov 12 '22 04:11

markoo