This page looks best with JavaScript enabled

Interpolated Strings in C# - Quick Tip

 ·   ·  ☕ 1 min read

C# has the ability to build strings in a number of ways. The simplest is concatenating them, but it’s not always the easiest or best solution depending on what you’re making. There’s a new solution that has been recently introduced to C# that allows you to interpolate strings in a very clean and readable way by embedding variables or functions directly into strings.

An example of what using string interpolation like this might look like:

1
2
var name = "World of Zero";
Console.WriteLine($"Hello {name}");

This feature became available in C# 6 and is usable in all versions after that. You may read more about it on MSDN: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated

The World of Zero Discord Server: https://discord.gg/hU5Kq2u


Sam Wronski
WRITTEN BY
Sam Wronski
Maker of things, currently helping build cloud things @ Google. World of Zero is a personal project disconnected from my professional work. Lets make something awesome together!