Use Convert.ToInt32
from mscorlib
as in
decimal value = 3.14m;
int n = Convert.ToInt32(value);
See MSDN. You can also use Decimal.ToInt32
. Again, see MSDN. Finally, you can do a direct cast as in
decimal value = 3.14m;
int n = (int) value;
which uses the explicit cast operator. See MSDN.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…