Bug solved by other way ,is it correct?

this the code i used

private void ManageMethod()
{
var nextStates = state.GetNextState(); //var refers to state//
int p = nextStates.Length;
if (Input.GetKeyDown(KeyCode.Alpha1) && p >=1)
{
state = nextStates[0];
}
else if (Input.GetKeyDown(KeyCode.Alpha2) && p >= 2)
{
state = nextStates[1];
}
else
{
state = state;
}
textComponent.text = state.GetStateStory();
}

Privacy & Terms