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 and professional software engineer. Lets make something awesome together!