Skip to content
AgileLogics
3 min read

String Interpolation

Prerequisites: Strings

A $"..." string embeds expressions directly, using {} — C#'s equivalent of JavaScript's template literals or Python's f-strings:

string name = "Ada";
int age = 36;
Console.WriteLine($"{name} is {age} years old");
Console.WriteLine($"Pi is about {3.14159:F2}"); // Pi is about 3.14

This has almost entirely replaced older string.Format(...)-style calls in modern C# code.