I have the following enum
in my code:
[Flags]
public enum Column
{
FirstName = 1 << 0,
LastName = 1 << 1,
Address = 1 << 2,
}
Now I have a method that can take a enum
.
public void ParseColumns(Column col)
{
//do some parsing...
}
This method can be called like this:
ParseColumns(Column.FirstName | Column.LastName);
ParseColumns(Column.LastName);
ParseColumns(Column.LastName | Column.Address | Column.FirstName);
ParseColumns(Column.Address | Column.FirstName);
I now need to iterate through the values but keep the order in which the enum
was passed to the methods.
I have found the following method which gave me the possibility to iterate through them, but sadly it returns the Order in which its defined in the Enum
itself and not how I called the method.
Iterate over values in Flags Enum?