0

Hi!!!

i have made a window application for solving mathematical expression using bodmas rule....

In that I am getting error IndexOutOfBound exception

```
private void button5_Click(object sender, EventArgs e)
{
string[] operands = this.textBox1.Text.Split('+', '-', '*', '/'); string[] operators = this.textBox1.Text.Split('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
List<string> l1 = operators.ToList();
foreach(string i in l1)
this.listBox1.Items.Add(i);
//Multiply and divide
for(int i = 0; i < operators.Length; ++i)
{
char[] a1 = operators[i].ToCharArray();
char op =a1[i];
int ss = Convert.ToInt32(operands[i]);
int ss1 = Convert.ToInt32(operands[i + 1]);
if(op == '/' || op == '*')
{
double answer = 0;
switch(op)
{
case '*':
answer = ss * ss1;
break;
case '/':
if(ss1 == 0)
MessageBox.Show("Cannot divide by zero");
answer = ss / ss1;
break;
}
ss = (int)answer;
ClearUsedTokens(operands,operators,i);
}
}
//Add and subtract
for(int i = 0; i < operators.Length; ++i)
{
int vv = Convert.ToInt32(operands[i]);
int vv1 = Convert.ToInt32(operands[i + 1]);
char[] a11 = operators[i].ToCharArray();
char op1 = a11[i];
if(op1 == '+' || op1 == '-')
{
double answer = 0;
switch(op1)
{
case '+':
answer = vv + vv1;
break;
case '-':
answer = vv - vv1;
break;
}
vv = (int)answer;
ClearUsedTokens(operands,operators,i);
}
}
this.textBox2.Text= operands[0].ToString();
}
}
```

Its giving error for line:" char op =a1*; "
Can anyone tell me how to modify my code.......*