Use scientific decimal literal - CSharp Language Basics

CSharp examples for Language Basics:decimal

Description

Use scientific decimal literal

Demo Code

using System;//from  ww w . j a  va 2  s  .co m
// Calculates the mass of 100 electrons;
class Constants
{
   public const decimal MassOfElectron = 9.0E-28m;
}
class MassCalculator
{
   public static void Main()
   {
      decimal totalMass;
      totalMass = 100 * Constants.MassOfElectron;
      Console.WriteLine(totalMass);
   }
}

Result


Related Tutorials