C#简单计算器如何实现小数点运算~望各位大虾帮忙解答
各位大虾看看,我这么写根本就不跟我小数点的概念~~~~~~很是郁闷了,还有怎么能实现打印结果为 2+3=5!
现在输入2显示(2),+显示空白,3只显示(3),=只显示(5);
想要输入2显示(2),接着输入+显示(2+),输入3显示(2+3),输入=显示(2+3=5);
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace calc
{
public partial class Form1 : Form
{
int a = 0;
int b = 0;
double result = 0.0;
char c;
bool joiy = true;
public Form1()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
Console.WriteLine(a);
}
private void button16_Click(object sender, EventArgs e)
{
if (joiy == false)
{
b = (int)result;
joiy = true;
}
else
{
if (b == 0)
{
b = a;
}
else
{
b -= a;
}
}
a = 0;
this.textBox1.Text = "";
c = '_';
}
private void button17_Click(object sender, EventArgs e)
{
if (joiy == false)
{
b = (int)result;
joiy = true;
}
else
{
if (b == 0)
{
b = a;
}
else
{
b += a;
}
}
a = 0;
this.textBox1.Text = "";
c = '+';
}
private void button14_Click(object sender, EventArgs e)
{
if (joiy == false)
{
b = (int)result;
joiy = true;
}
else
{
if (b == 0)
{
b = a;
}
else
{
b *= a;
}
}
a = 0;
this.textBox1.Text = "";
c='*';
}
private void button15_Click(object sender, EventArgs e)
{
if (joiy == false)
{
b = (int)result;
joiy = true;
}
else
{
if (b == 0)
{
b = a;
}
else
{
b /= a;
}
}
a = 0;
this.textBox1.Text = "";