Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 尝试将计算器文本框项转换为int和char(用于+;*等),或将它们与start分开_C#_Textbox_Calculator - Fatal编程技术网

C# 尝试将计算器文本框项转换为int和char(用于+;*等),或将它们与start分开

C# 尝试将计算器文本框项转换为int和char(用于+;*等),或将它们与start分开,c#,textbox,calculator,C#,Textbox,Calculator,我在编写一个计算器时遇到了一个问题,它可以在文本框中显示一个均衡值,如 25*3(6-5)^2然后将它们放入不同的数组中,以破坏ofc的订单 在将它们放入文本框之前,我首先尝试将它们分开,因此我使用了以下代码: namespace CalculatorForDS { public partial class Form1 : Form { public int i=0, j=0, x; int[] a; int[] b;

我在编写一个计算器时遇到了一个问题,它可以在文本框中显示一个均衡值,如
25*3(6-5)^2
然后将它们放入不同的数组中,以破坏ofc的订单

在将它们放入文本框之前,我首先尝试将它们分开,因此我使用了以下代码:

namespace CalculatorForDS
{
    public partial class Form1 : Form
    {
        public int i=0, j=0, x;
        int[] a;
        int[] b;
        char[] c;

        void Process()
        {
            a = new int[100];
            b = new int[100];
            c = new char[100];
        }
        public Form1()
        {
            InitializeComponent();
            Process();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 1;
            a[i] = a[i] * 10^j + 1;
            j++;
            x = a[i];
        }

        private void button16_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "(";
            c[i] = '(';
            i++;
            j = 0;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 2;
            a[i] = a[i] * 10^j + 2;
            j++;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 3;
            a[i] = a[i] * 10^j + 3;
            j++;
        }

        private void button4_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 4;
            a[i] = a[i] * 10^j + 4;
            j++;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 5;
            a[i] = a[i] * 10^j + 5;
            j++;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 6;
            a[i] = a[i] * 10^j + 6;
            j++;
        }

        private void button7_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 7;
            a[i] = a[i] * 10^j + 7;
            j++;
        }

        private void button8_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 8;
            a[i] = a[i] * 10^j + 8;
            j++;
        }

        private void button9_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 9;
            a[i] = a[i] * 10^j + 9;
            j++;
        }

        private void button17_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + ")";
            c[i] = ')';
            i++;
            j = 0;
        }

        private void button18_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "^";
            c[i] = '^';
            i++;
            j = 0;
        }

        private void button12_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "/";
            c[i] = '/';
            i++;
            j = 0;
        }

        private void button19_Click(object sender, EventArgs e)
        {
            int lenght = textBox1.TextLength - 1;
            string text = textBox1.Text;
            textBox1.Clear();
            for (int i = 0; i < lenght; i++)
                textBox1.Text = textBox1.Text + text[i]; 
        }

        private void button13_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "*";
            c[i] = '*';
            i++;
            j = 0;
        }

        private void button14_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "-";
            c[i] = '-';
            i++;
            j = 0;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + "+";
            c[i] = '+';
            i++;
            j = 0;
        }

        private void button11_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + ".";
            c[i] = '.';
            i++;
            j = 0;
        }

        private void button10_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text + 0;
            a[i] = a[i] + j * 0;
            j++;
        }

        private void button20_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(a[i]);
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
    }
}
名称空间计算器fords
{
公共部分类Form1:Form
{
公共整数i=0,j=0,x;
int[]a;
int[]b;
char[]c;
无效过程()
{
a=新整数[100];
b=新整数[100];
c=新字符[100];
}
公共表格1()
{
初始化组件();
过程();
}
私有无效按钮1\u单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+1;
a[i]=a[i]*10^j+1;
j++;
x=a[i];
}
私有无效按钮16_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+“(”;
c[i]='(';
i++;
j=0;
}
私有void Form1\u加载(对象发送方、事件参数e)
{
}
私有无效按钮2\u单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+2;
a[i]=a[i]*10^j+2;
j++;
}
私有无效按钮3\u单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+3;
a[i]=a[i]*10^j+3;
j++;
}
私有无效按钮4_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+4;
a[i]=a[i]*10^j+4;
j++;
}
私有无效按钮5_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+5;
a[i]=a[i]*10^j+5;
j++;
}
私有无效按钮6_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+6;
a[i]=a[i]*10^j+6;
j++;
}
私有无效按钮7_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+7;
a[i]=a[i]*10^j+7;
j++;
}
私有无效按钮8_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+8;
a[i]=a[i]*10^j+8;
j++;
}
私有无效按钮9_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+9;
a[i]=a[i]*10^j+9;
j++;
}
私有无效按钮17_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+”;
c[i]=')';
i++;
j=0;
}
私有无效按钮18_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+“^”;
c[i]='^';
i++;
j=0;
}
私有无效按钮12_单击(对象发送者,事件参数e)
{
textBox1.Text=textBox1.Text+“/”;
c[i]='/';
i++;
j=0;
}
私有无效按钮19_单击(对象发送者,事件参数e)
{
int lenght=textBox1.TextLength-1;
string text=textBox1.text;
textBox1.Clear();
对于(int i=0;i

有了上面的代码,我可以在我的程序中做我想做的事情,也就是把中缀表达式变成后缀:D

我对我的程序做了一些更改,但最后它仍然有pr