Passing a parameter through a generic method?

Hi, I’m trying to create a state machine. However, I’m having trouble with retrieving a parameter.

Right now, I have:

    private IStateMachine currentState;

    void ChangeState<T>() where T : IStateMachine
    {
        //Make currentState equal to the parameter being passed to ChangeState
        currentState = newState;
    }

As an example, here’s what I want in a non-generic method:

    void GetNumber(int number)
    {
        int newNumber = number;
    }

Also, I’d like to know how to call the generic method. Something like:

    void Start()
    {
        GetNumber(5);
    }

Hi

What problem are you having? I don’t even see a parameter in your first snippet.

AFAICS If you change it to the following it should do:

void ChangeState<T>(T newState) where T : IStateMachine
{
        //Make currentState equal to the parameter being passed to ChangeState
        currentState = newState;
}

Best

Adriano