Users Pricing

forum

Home Forums Sort enums in declaration order – MindStick

Sort enums in declaration order

Manoj Bhatt 2265 14 Aug 2014
public enum CurrencyId
{
    USD = 840,
    UAH = 980,
    RUR = 643,
    EUR = 978,
    KZT = 398,
    UNSUPPORTED = 0
}

Is there any way to sort results of Enum.GetValues(typeof(CurrencyId)).Cast<CurrencyId>() by order they are declared in .cs file (USD, UAH, RUR, EUR, KZT, UNSUPPORTED), not by their underlying code? Personally, I believe the answer is 'no', because original order is lost in binaries, so... how can I implement the task?


1 Answers

Markdown for AI

A clean, structured version of this page for AI assistants and LLMs.

Open .md