Format Price Interpolated in Verbatim String - CSharp Language Basics

CSharp examples for Language Basics:Data Type Format

Description

Format Price Interpolated in Verbatim String

Demo Code

using System;/* ww w.  j av  a2s  .c  om*/
using System.ComponentModel;

   public class FormatPriceInterpolatedVerbatim
   {
      static void Main()
      {
         decimal price = 95.25m;
         decimal tip = price * 0.2m;
         Console.WriteLine($@"Price: {price,9:C}
         Tip:   {tip,9:C}
         Total: {price + tip,9:C}");
      }
   }

Result


Related Tutorials