Не срабатывает Boolean a; a = true; - C#
Формулировка задачи:
код программы калькулятор может кто имеет интересней алгоритм программы? не срабатывает a = true; как исправить Boolean a; a = true;?.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication15
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
char kod='0';
switch (kod)
{
/* case kod='+':
X = Convert.ToInt32(textBox1.Text);
Y = Convert.ToInt32(textBox1.Text);
textBox1.text=Convert.ToStr(X+Y);
break;
case kod = '-':
break;
case kod = '*':
break;
case kod = '/':
break; */
}
}
private void button14_Click(object sender, EventArgs e)
{
char kod;
kod = '+';
int X,Y;
Boolean a;
X = Convert.ToInt32(textBox1.Text);
textBox1.Clear();
MessageBox.Show("kod");
Y = Y + Convert.ToInt32(textBox1.Text);
if (kod=='+') {
a = false;
}
object a = null;
}
private void button15_Click(object sender, EventArgs e)
{
char kod;
kod = '-';
var X = Convert.ToInt32(textBox1.Text);
var Y =Convert.ToInt32(textBox1.Text);
}
private void button16_Click(object sender, EventArgs e)
{
char kod;
kod = '*';
var Y = Convert.ToInt32(textBox1.Text);
}
private void button17_Click(object sender, EventArgs e)
{
char kod;
kod = '/';
var Y = Convert.ToInt32(textBox1.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
int X,Y;
Boolean a; a = true;
if(a==true) {
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "1";
X = Convert.ToInt32(textBox1.Text);
}
else
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "1";
Y = Convert.ToInt32(textBox1.Text)}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "2";
}
bool a;
a = true;
}
private void button13_Click(object sender, EventArgs e)
{
textBox1.Clear();
}
private void button12_Click(object sender, EventArgs e)
{
int iy,i;
iy= Convert.ToInt32(textBox1.Text);
i = iy * iy;
textBox1.Text = Convert.ToString(i);
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "3";
}
bool a;
a = true;
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "4";
}
bool a;
a = true;
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "5";
}
bool a;
a = true;
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "6";
}
bool a;
a = true;
}
private void button8_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "7";
}
bool a;
a = true;
}
private void button9_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "8";
}
bool a;
a = true;
}
private void button10_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "9";
}
bool a;
a = true;
}
private void button11_Click(object sender, EventArgs e)
{
if (textBox1.Text == "0")
{
textBox1.Clear();
textBox1.Text = textBox1.Text + "0";
}
bool a;
a = true;
}
}
}Решение задачи: «Не срабатывает Boolean a; a = true;»
textual
Листинг программы
private bool _a = false; //например
public Form1()
{
InitializeComponent();
}
//...