simple c# arithmetics. winForms
- by jello
I'm doing simple divisions in c#, and I am a bit puzzled by its intricacies. Here's some code, and in the comments, the result. (btw, I only compile with 1 line not commented, if you say that I have 5 declarations of the same variable)
double result = 2 / 3; //gives 0
double result = Convert.ToDouble(2) / Convert.ToDouble(3); // is good
double result = double.Parse(2) / double.Parse(3); // gives me errors
double result = double.Parse(2 / 3); // gives me errors
double result = Convert.ToDouble(2 / 3); // gives 0
MessageBox.Show(result.ToString());
so if you have a bunch of integers you wanna mess with, you have to convert each one to a double. pretty tedious...