I am still making a few assumptions when I provide this code. First I am assuming that the text of the buttons will be the number, and second that you want the integer value associated with the button.
public Form1()
{
InitializeComponent();
}
private void button_Click(object sender, EventArgs e)
{
Debug.Assert(sender is Button);
var btn = (Button)sender;
IsNumeric(btn.Text);
var number = int.Parse(btn.Text);
}
[Conditional("Debug")]
private void IsNumeric(string value)
{
int temp;
Debug.Assert( int.TryParse(value, out temp));
}
I also put in code for debugging. You have to wire up each number button to use the button_Click on the clidk event. That code is in the code behind.