I am making an algebra equation solver in which you enter 2 values and gives you the x value in a format of x + (value1)= (value2).
I figured out how to convert the data given in value1 and value2 to an integer but value one gets stuck in a private void and I can't use it outside of that void. How am I able to use value1 and value2 outside their respective private voids?
If you figured that out, how am I able to output the value of x into the program windows ( I'm creating a windows form application)?
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 equation_solver
{
public partial class EquationSolver : Form
{
public EquationSolver()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
int z;
z = Convert.ToInt32(textBox1.Text);
z = int.Parse(textBox1.Text);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
int y;
y = Convert.ToInt32(textBox1.Text);
y = int.Parse(textBox1.Text);
}
}
}
y = Convert.ToInt32(textBox1.Text); y = int.Parse(textBox1.Text);is doing exactly the same operation twice. There is no purpose to using both; the result of both calls is an int.