Update documentation for constant interpolated strings - #55888
Update documentation for constant interpolated strings#55888asundheimMSFT wants to merge 1 commit into
Conversation
Clarifythat interpolated expressions must be constant strings for building constant interpolated strings, fix spacing between sentences.
There was a problem hiding this comment.
🟢 Approval recommended
The update is small, accurate relative to the accompanying example snippet, and improves clarity without introducing new issues.
Pull request overview
This PR updates the C# string interpolation documentation to clarify the rules for constant interpolated strings and correct a sentence-spacing issue, reducing confusion about why non-string constants (for example, const int) can’t be interpolated in a constant context.
Changes:
- Clarified that each interpolated expression must be a constant
stringvalue for the overall interpolated string to be a compile-time constant. - Fixed missing whitespace between sentences in the “Build constant strings” section.
File summaries
| File | Description |
|---|---|
| docs/csharp/fundamentals/strings/interpolation.md | Clarifies the “constant interpolated strings” requirement and fixes sentence spacing for readability. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
FWIW this page: https://ironsoftware.com/academy/whats-new-in-csharp-and-dotnet/csharp-constant-interpolation-dotnet6-10-minutes/ seems to poison AI search engine results: We should probably be more forceful about the distinction in our docs (but this version of the changes seemed the most straightforward / un-objectionable for now.) |

Overview
Clarify that interpolated expressions must be constant strings for building constant interpolated strings, fix spacing between sentences.
Details
Reading the old version, you might get confused as to why you cannot interpolate

constintegral values into strings, like this:Also the sentence was missing a space after the

.:Internal previews
Build report