Change gameobject's sprite from array when clicking on a button

I have Sprite with some sprites. When i press a Button I want to change sprites in order, from index 0 to sprite lenght.

for (int i = 0; i < poseta.Length; i++)
        {
            pst.GetComponent<SpriteRenderer>().sprite = poseta*;*

}
I’ve tried this, but it change to last index.
for (int i = 0; i < poseta.Length; i++)
{
pst.GetComponent().sprite = poseta*;*
}
And there I get an error that the object reference not set an instance.

private int spriteIndex = 0 ;

// In the inspector :
// 1. Select the button
// 2. Add a new callback in the 'OnClick' event of the button
// 3. Drag & Drop the script holding the script used to change the sprite
// 4. Select the name of the script and the `SelectNextSprite` function
public void SelectNextSprite()
{
    spriteIndex = (spriteIndex + 1) % poseta.Length ;
    pst.GetComponent<SpriteRenderer>().sprite = poseta[spriteIndex];
}