public partial class Form1 : Form
{
public double operatore1 = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void Numeri(double num)
{
double num1 = num;
string display = Convert.ToString(num);
if (textBox1.Text.Length == 10)
{
MessageBox.Show("Inserire massimo 10 numeri.");
}
else
{
textBox1.AppendText(display);
}
}
public void operazione(string op)
{
double operatore1 = Convert.ToDouble(textBox1.Text);
string operazione = op;
string display = op;
textBox1.Text = display;
}
public void button1_Click(object sender, EventArgs e)
{
Numeri(1);
}
public void button2_Click(object sender, EventArgs e)
{
Numeri(2);
}
public void buttonpiu_Click(object sender, EventArgs e)
{
operarazione("+");
}
public void buttonuguale_Click(object sender, EventArgs e)
{
double operatore2 = Convert.ToDouble(textBox1.Text);
double risultato = operatore2 + operatore1;
string display = Convert.ToString(risultato);
textBox1.Text = display;
}
}