C# 연습

Invoice and Numeric Formatting

C# composite formatting makes console reports readable without manual padding.

How it works

Format aligned currency output with interpolation.

Alignment components set field widths and the C format specifier uses the current culture's currency format.

Runnable C# example

C#
Run code →
Program.cs
using System;
class Program
{
    static void Main()
    {
        var lines = new[] { ("Book", 2, 12.50m), ("Pen", 3, 1.25m) };
        foreach (var (name, quantity, price) in lines)
            Console.WriteLine($"{name,-8} {quantity,2} {quantity * price,8:F2}");
    }
}
Expected output
Book      2    25.00
Pen       3     3.75

Practice with the debugger

Set a breakpoint on an important assignment or condition, click Debug, and inspect the local values before stepping to the next line.