Create a temp int and cast the real number to it, or use the cast in an expression.
using System;
class CastToInt {
public static int Main(string[] args) {
double pi = 3.14159265358979;
int nPi = (int)pi;
Console.WriteLine("pi = {0} and pi cast to int = {1}", pi, nPi);
Console.WriteLine("pi = {0} and pi cast to int = {1}", pi, (int)pi);
Console.Write("\nPress Enter to continue...");
Console.Read();
return 0;
}
}
"Homer Simpson" <homer@moe's.com> wrote in message news:eU**************@TK2MSFTNGP12.phx.gbl...
I'm using VS2005 Beta 2 (C#) and would like to know how I can remove the
decimal portion (to the right of the decimal) of a real number. I want the
whole number portion but do not wish to discard the decimal portion; that
will be used for additional calcs.
Does C# have any methods for doing this?
Thanks,
Scott