string interpolation
Embeds expressions directly in string literals using the $ prefix. Cleaner alternative to string.Format().
Syntax
csharp
$"text {expression} text"Example
csharp
string name = "Alice";
int age = 28;
string msg = $"Hello, {name}! You are {age} years old.";
double price = 9.99;
string formatted = $"Price: {price:C2}"; // "$9.99"
string multi = $"Full name: {user.FirstName} {user.LastName}";