Button onClick with delegate

How do I initialise a button onClick function on runtime? I got this error on the AddListener. error CS0119: Expression denotes a variable', where a method group’ was expected on line 15

public class ShopMenuController : MonoBehaviour
{
    public ShopMenuView _shopMenuView;

    public GameObject slotPrefab;
    public Transform contentTransf;
    public Sprite[] sprite;

    private delegate void MyDelegate(string type);
    private MyDelegate _onSelect;
 
    public void Awake()
    {
        _onSelect = OnSelect;
        LoadView ();
    }

    public void OnSelect(string type)
    {

    }

    public void LoadView()
    {
        _shopMenuView = new ShopMenuView (slotPrefab, contentTransf, sprite, _onSelect);
    }
}
public class ShopMenuView : MonoBehaviour
{
    public ShopMenuView(GameObject slotPrefab, Transform contentTransf, Sprite[] sprite, Delegate onSelect)
    {
        int count = Enum.GetNames (typeof(ShopItemType)).Length;
        print (count);
        for (int i = count - 1; i >= 0; i--)
        {
            print (slotPrefab);
            GameObject go       = Instantiate(slotPrefab) as GameObject;
            go.transform.parent = contentTransf;
            go.name             = sprite[i].name;
            print (onSelect);
            go.GetComponent<Image>().sprite = sprite[i];
            go.GetComponent<Button>().onClick.AddListener(() => onSelect(go.name));
        }
    }
}

I’m just learning delegates, but I think it’s supposed to be:
_onSelect = new _onSelect(onSelect);

In here, you were using “Delegate” instead of “MyDelegate”

public ShopMenuView(GameObject slotPrefab, Transform contentTransf, Sprite[] sprite, MyDelegate onSelect

But that means you need to declare it a public.

public delegate void MyDelegate(string type);

Thanks! Solved!

Declare this outside of the class.
public delegate void MyDelegate(string type);