CSharp examples for Language Basics:Data Type Cast
Convert decimal to int with Convert.ToInt32
using System;/*from w ww .j av a 2 s.c o m*/ class MassCalculator { const decimal MassOfElectron = 9.0E-28m; public static void Main() { decimal totalMass; int electronAmount; Console.WriteLine("Enter number of electrons"); electronAmount = Convert.ToInt32(Console.ReadLine()); totalMass = MassOfElectron * electronAmount; Console.WriteLine("Mass of " + electronAmount + " electrons: " + totalMass + " grams"); } }