Let's say I have an enum
like such:
public enum Something
{
This = 10,
That = 5,
It = 11
}
I would like to know if its possible to get the next enum
based on the order they are and not their value or name.
Unhappily I have no control over the numbers, I can only change the names.
For example, if I have That
the next is It
and not This
.
Pseudo code:
var current = Something.That;
Console.WriteLine(current);
// prints That
current = GetNextEnum(Something.That);
// prints It
Console.WriteLine(current);
current = GetNextEnum(Something.It);
// prints This
Console.WriteLine(current);
// And so the cycle continues...
Is there any way to achieve this?
UPDATE:
I can't execute more than one state per pulse, so I need to know which state I have ran to know which state to run next, for example:
private Something _state = Something.That;
private void Pulse()
{
// this will run every pulse the application does
foreach (var item in (Something)Enum.GetValues(typeof(Something)))
{
if (_state == item)
{
// Do some stuff here
}
_state = next item;
return;
}
}
Am also trying to avoid to make a block for each state and rather have the states being executed dynamically as they can be added or removed.
So my real question is how can I know what comes next and where I am.