To add to my answer that Rick linked to, inside the button event handler you can access the actual button that was clicked via the
sender
parameter:
private void MyButton_Click(object sender, EventArgs e)
{
if (sender is Button btn)
{
Console.WriteLine(btn.Text);
...
}
}
"looping through" buttons doesn't make any real sense, as the user can only physically click on one of them at a time!