Spawn meshes to scene via dropdown UI button

Hello. I am a new programmer and i want your help. I am working a project where i try to select and spawn a primitive mesh in scene via a dropdown button. I never use something like that so if anyone can help me. I have made an array wich i include my primitives meshes and i want to select them when i select the dropdown options. Here is my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ChangeMeshFilter : MonoBehaviour
{
public Mesh myMesh= new Mesh[5];
private int a = 0;
private GameObject gObject;
public Dropdown MeshSelector;

void Start () 
{
    CreateObject();
 
}

void CreateObject() {
    gObject = new GameObject();

    gObject.AddComponent<MeshFilter>().mesh = myMesh[0] ;
    gObject.AddComponent<MeshRenderer>();
    gObject.GetComponent<MeshRenderer>().material.color = Color.green;
}

public void Changer() 
{
    if (a < 4)
        {
            a = a + 1;
        }
        else
        {
            a = 0;
        }

        gObject.GetComponent<MeshFilter>().mesh = myMesh[a];
}

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class ChangeMeshFilter : MonoBehaviour
{
    public Mesh[] myMesh= new Mesh[5];
    private GameObject gObject;
    public Dropdown MeshSelector;
 
    void Start () 
    {
        CreateObject();
        MeshSelector.onValueChanged.AddListener(SelectMesh);
    }

    void CreateObject() {
        gObject = new GameObject();
 
        gObject.AddComponent<MeshFilter>().mesh = myMesh[0] ;
        gObject.AddComponent<MeshRenderer>();
        gObject.GetComponent<MeshRenderer>().material.color = Color.green;
    }
 
    private void SelectMesh(int index) 
    {     
            gObject.GetComponent<MeshFilter>().mesh = myMesh[index];
    }

Hi,

Could you please clarify if you want to have an inspector attribute with a dropdown via which you select the type of mesh you want to spawn in your scene or you wan this function to be during run-time in UI?

if you want to make this in the inspector then do this

enum DDLEnum
 {
    Item1, 
    Item2, 
    Item3
 };
 var dropDown = DDLEnum.Item1;