how to insert coroutine along with case

I have a check between 0 and 3, which are the 3 cases, I am trying to insert a routine, but in doing so I can no longer access my cases.

    public int index;
    private void Start()
    {
        StartCoroutine(indice());
    }

    public void previous()
    {
        index--;
        voidindex();
    }

    public void next()
    {
        index++;
        voidindex();
    }

    void voidindex()
    {
        if (index <= 0)
        {
            index = 0;
        }

        if (index >= 3)
        {
            index = 3;
        }
    }

    IEnumerator indice()
    {
        switch (index)
        {
            case 0:
            {
                yield return new WaitForSeconds(0.1f);
                print("0");
            }

            break;
            case 1:
            {
                yield return new WaitForSeconds(0.1f);
                print("1");
            }

            break;

            case 2:
            {
                yield return new WaitForSeconds(0.1f);
                print("2");
            }

            break;

            case 3:
            {
                yield return new WaitForSeconds(0.1f);
                print("3");
            }

            break;
        }
    }
}

What do you mean you can’t access your cases?
You’re missing two closing brackets, but I’m guessing that’s copy/paste error.

As far as what I’m seeing, you are trying to pass an int to your coroutine, but you also appear to have a field(class variable) named index, so there isn’t a reason to pass it in. Your coroutine is trying to use the parameter. Just because they are named the same doesn’t mean they are the same. Remove the int index from the coroutine (unless you actually mean to pass it in, in which case, show the rest of your script)

not much to complement, the only thing missing is the startup routine at start

as you can see, adding ienumerator, there is a pause because the check closes,as you can see on lines 12 and 14.
so my verification can’t go through the cases

Sorry, you’re not making any sense.
Switch statements work just fine in a coroutine. There is nothing a coroutine does that would change how a switch behaves.

Line 12 is a closing bracket. Line 14 is your coroutine start. So I don’t know what you are trying to do. Right now your coroutine isn’t even being run. You don’t have a StartCoroutine call in what you showed.

If you want to call your coroutine, you have to use StartCoroutine and pass in the index value. That is why I asked you to show your code since you don’t appear to be doing that anywhere.

I also thought I was right
I removed the ienumerator index and added a debug to each one, try to see and see that the thing is different.

add for each button the previous and next function

Ok, so right now your coroutine runs once in Start. If you want it to run after you change it’s value, you need to call it again in your voidindex method.