use the Convert.ToInt32() method or the type cast (int) operator.
xxxxxxxxxx
double myDouble = 3.14;
int myInt1 = Convert.ToInt32(myDouble); // method 1
int myInt2 = (int)myDouble; // method 2
Console.WriteLine(myInt1); // output: 3
Console.WriteLine(myInt2); // output: 3
Note that when converting from a double to an int, the decimal portion of the number is truncated.
use the decimal type's constructor that takes a double value as an argument.
xxxxxxxxxx
double doubleValue = 3.14159;
decimal decimalValue = new decimal(doubleValue);
the doubleValue variable is converted to a decimal and stored in the decimalValue variable.
Note that converting from double to decimal can result in a loss of precision, as double can represent a wider range of values than decimal.