xFear of Napalm
06-12-2010, 12:30 AM
I'm sorry if I'm missing something dead
basic, but I'm extremely new to C#, and
basically all programming in general. I'm
trying to build some basic things on my
own to practice Syntax and get a better
feel for the language. I'm currently using
Visual C# Express 2010, and I'm writing a
simple-as-hell program to covert Celsius
temperatures to Fahrenheit, and vise versa.
For some reason, when I enter a temperature
in the Fahrenheit textBox, "fText", and try
to convert it, it will always equal zero in the
Celsius textBox, cText. My integers for the
temperatures are f and c. Could this alone
cause this problem?
Here is my code for my Fahrenheit to Celsius
button, the only one I've completed. Is there
anything visibly wrong?
private void fcButton_Click(object sender, EventArgs e)
{
int f;
int c;
f = int.Parse(fText.Text);
c = ((5 / 9) * (f - 32));
cText.Text = Convert.ToString(c);
}
Should the variables be declared elsewhere?
Does the last line not work like I think it should?
What's a good alternative to this, and why?
Thanks for helping, and just remember, I'm as
new to this as humanly possible, and internet-
taught. Also, I'm sorry for taking this much room
to post my problem, I just wanted to be descriptive.
basic, but I'm extremely new to C#, and
basically all programming in general. I'm
trying to build some basic things on my
own to practice Syntax and get a better
feel for the language. I'm currently using
Visual C# Express 2010, and I'm writing a
simple-as-hell program to covert Celsius
temperatures to Fahrenheit, and vise versa.
For some reason, when I enter a temperature
in the Fahrenheit textBox, "fText", and try
to convert it, it will always equal zero in the
Celsius textBox, cText. My integers for the
temperatures are f and c. Could this alone
cause this problem?
Here is my code for my Fahrenheit to Celsius
button, the only one I've completed. Is there
anything visibly wrong?
private void fcButton_Click(object sender, EventArgs e)
{
int f;
int c;
f = int.Parse(fText.Text);
c = ((5 / 9) * (f - 32));
cText.Text = Convert.ToString(c);
}
Should the variables be declared elsewhere?
Does the last line not work like I think it should?
What's a good alternative to this, and why?
Thanks for helping, and just remember, I'm as
new to this as humanly possible, and internet-
taught. Also, I'm sorry for taking this much room
to post my problem, I just wanted to be descriptive.