Creating Buttons that change an int Value

I’m creating a game where a set of questions pop up on screen with code. All the text is created with code and their placement is created with code, as well as the buttons themselves. When the player clicks on one of the buttons, depending on the button, I need to change an int value and delete that button. How can I do that?

for (int i = 3; i < readline.Length; i++)
{

        askedQuestion.text = readLine*;*

RectTransform questionTransform = ((GameObject)Instantiate(question)).GetComponent();
questionTransform.SetParent(questionPanel);
}

You’re probably looking for Button.onClick.

@Kishotta 's answer is correct, but incomplete, and can lead you to some problems if you are not aware. You may face the problem of closures. Take a look at the code below to prevent this problem :

private int myInt ;

// ....
for (int i = 3; i < readline.Length; i++)
 { 
         int closureIndex = i ;
         askedQuestion.text = readLine*;*

RectTransform questionTransform = ((GameObject)Instantiate(question)).GetComponent();
questionTransform.GetComponent().onClick.AddListener( () =>
{
myInt = closureIndex ;
Destroy( questionTransform.gameObject ) ;
} ) ;
questionTransform.SetParent(questionPanel);
}