unity onclick addlistener

C#
public int index;  
private Button myselfButton;   

void Start()  
{      
  myselfButton = GetComponent<Button>();      
  myselfButton.onClick.AddListener(() => actionToMaterial(index));  
}   

void actionToMaterial(int idx)  
{      
  Debug.Log("change material to HIT  on material :  " + idx);  
}

void Destroy()
{
  myselfButton.onClick.RemoveListener(() => actionToMaterial(index));
}
Source

Also in C#: