Refering to gameObject variable from string

I’m trying to randomly instantiate a gameObject, of which I already have variables for. I’m not sure if it’s something obvious or not, but it makes more sense with the code:

public GameObject object0;
public GameObject object1;      /*Choosing one of these randomly*/
public GameObject object2;

void Start() {
    private int random = Random.Range(0, 3); /*Picking which object*/
    private string object = "object" + random);  /*Where the problem is, appending the number to object*/
    Instantiate(object);   /*I don't know how to refer to a gameObject variable as a string.*/
}

Ideally I want the same effect as changing the second to last line to “Instantiate(object1);”

Take a look at the answer I gave here

But, I don’t feel it’s the right way to do so.

You should use a simple array :

 public GameObject[] objects;
 
 void Start() {
     Instantiate(objects[Random.Range(0,3)]);
 }