By 22/07/2015 14 Comments

C# Decimal

  • Decimal data type is used for monetary calculations.
  • It is being used for computations that involve money.
  • It is used for financial calculations, such as calculations discount prices, percentages etc.
  • The value which is being stored in decimal must be suffixed with character (m) (e.g.: 12.22m).
DATA TYPE WIDTH IN BITS RANGE
decimal 128 1E–28 to 7.9E+28

Example:

using System;
namespace csharpBasic
{
    // Start class definition / declaration.
    class Program
    {
        // Static main method void type declaration.
        static void Main(string[] args)
        {
            /* decimal type variable initialization.
             * A character M is being used as a suffix which indicates that this is a decimal type.
            */
            decimal price = 155.2M;

            // Print variable.
            Console.WriteLine("Price: " + price);
            Console.ReadKey();

        } // End of main method definition. 
    } // End of class. 
}





Next Tutorial →


← Previous Tutorial


Posted in: C# Basics, C#.NET

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .