How to get the numeric value from the Enum?

.net, c#, enums, properties, reflection

Solution

For the majority of Enum's simply cast to the base type which is int32.

int value = (int)System.Net.HttpStatusCode.Forbidden;

Problem

For example System.Net.HttpStatusCode Enum, I would like to get the HTTP Status Codes instead of the HTTP Status Text. `System.Net.HttpStatusCode.Forbidden` should return 403 instead of "Forbidden". How can I extract the value?

Original source

Related problems