Skip to content

Commit 9f475f6

Browse files
authored
Add example of concatenated interpolated strings (#29785)
1 parent 66ef334 commit 9f475f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/csharp/language-reference/tokens/interpolated.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,20 @@ The following example uses implicit conversion to <xref:System.FormattableString
9494

9595
:::code language="csharp" source="./snippets/string-interpolation.cs" id="Snippet4":::
9696

97+
## Combining multiple interpolated strings
98+
99+
To combine multiple interpolated strings, use the interpolation expression for each:
100+
101+
```csharp
102+
var firstWord = "Hello";
103+
var secondWord = "World";
104+
105+
var combinedInterpolatedString = $"{firstWord}, " + $"{secondWord}!";
106+
107+
Console.WriteLine(combinedInterpolatedString)
108+
// output: "Hello, World!"
109+
```
110+
97111
## Other resources
98112

99113
If you're new to string interpolation, see the [String interpolation in C#](../../tutorials/exploration/interpolated-strings.yml) interactive tutorial. You can also check another [String interpolation in C#](../../tutorials/string-interpolation.md) tutorial. That tutorial demonstrates how to use interpolated strings to produce formatted strings.

0 commit comments

Comments
 (0)