I am new to C# programming and am very inexperienced.
I'm creating a form with a text box, and I want my program to read numbers in that box in a method, and execute an operation with those numbers in another method. Here's how it is by now:
public void readG_TextChanged(object sender, EventArgs e)
{
string _G = readG.Text;
decimal _Gd = Convert.ToDecimal(_G);
}
public void readQ_TextChanged(object sender, EventArgs e)
{
string _Q = readQ.Text;
decimal _Qd = Convert.ToDecimal(_Q);
}
private void button1_Click(object sender, EventArgs e)
{
decimal _ULS = (1.35m * _Gd + 1.5m * _Qd);
Console.WriteLine("{0}", _ULS);
}
readQ, readG are the boxes names. button1 is the button to proceed to the operation, and display it in a console.
So far I have the _Gd and _Qd out of context in the button1_click method. Besides that, I think it will run pretty fine.
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…