public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string str, s1, s2, operation;
int index, no1, no2, sum;
str = textBox1.Text;
index = str.IndexOf('+');
s1 = str.Substring(0, index);
s2 = str.Substring(index + 1);
operation = str.Substring(index, 1);
no1 = Convert.ToInt16(s1);
no2 = Convert.ToInt16(s2);
sum = no1 + no2;
MessageBox.Show(sum.ToString());
}
}
}
المطلوب اذا وضعت اشارة ضرب يقوم بعملية الضرب
واذا وضعت اشارة طرح ان يقوم بعملية الطرح
وان يتم ذالك باستخدم if وelse وelse if
مع العلم ان لا يتم الغاء اي عملية من العمليات