Locked lesson.
About this lesson
We learn the difference between Concatenation and Interpolation, and when one might be easier to use than the other.
Exercise files
Download this lesson’s related exercise files.
12 - String Concatenation and Interpolation.docx60.8 KB 12 - String Concatenation and Interpolation SOLUTION.docx
57.7 KB
Quick reference
String Concatenation and Interpolation
String concatenation and interpolation allow you to add things to your strings, or edit them in real-time.
When to use
Use these whenever you need to modify your string.
Instructions
string name = "John";
Console.WriteLine(name + " Elder"); // concatenation
Console.WriteLine($"{name} Elder");
Hints & tips
- Concatenation uses "+" signs to add pieces of text together: Console.WriteLine(name + " Elder");
- Interpolation references variables within the WriteLine statement: Console.WriteLine($"{name} Elder");
Lesson notes are only available for subscribers.