Format Price Interpolated - CSharp Language Basics

CSharp examples for Language Basics:Data Type Format

Description

Format Price Interpolated

Demo Code

using System;/*from w ww  .ja  va  2  s.c  o m*/
using System.ComponentModel;
public class FormatPriceInterpolated
{
   static void Main()
   {
      decimal price = 95.25m;
      decimal tip = price * 0.2m;
      Console.WriteLine($"Price: {price,9:C}");
      Console.WriteLine($"Tip:   {tip,9:C}");
      Console.WriteLine($"Total: {price + tip,9:C}");
   }
}

Result


Related Tutorials