Feb 12, 2012 at 2:45 AM
Edited Feb 12, 2012 at 11:49 AM
Right, I've been having trouble when converting doubles to integers:
int someInt = 20;
double somedouble = (double)someInt;
This seems to work when I write the values to the console, but when I try this:
double somedouble = 20.2;
int someint = (int)somedouble;
It doesn't work.
I've tried making a function that rounds a double, converts that to a string, then returns the integer part, but it didn't work.
This is the conversion function I used, it works in a normal console application in .NET, I'm guessing that Double.toString() is not implemented yet.
public static int Round(double n)
string number = Math.Round(n).ToString();