Skip to content

Please provide example for combining raw string literals with interpolated string #42727

Open
@tobey74

Description

@tobey74

Type of issue

Missing information

Description

I keep forgetting how to combine raw string literal with interpolated strings which I use, but obviously not use enough apperantly, when testing and building json objects.
And my issue is the text here is just not clear enough for me to understand I both have to use multiple $ characters and multiple { and } so it would be very beneficial with an actual example in the documentation, something like 🙂

string jsonPayload = $$"""
{
    "firstName": {{firstname}},
    "lastName": "{{lastname}}"
}
""";

[Enter feedback here]
Raw string literals can also be combined with interpolated strings to embed the { and } characters in the output string. You use multiple $ characters in an interpolated raw string literal to embed { and } characters in the output string without escaping them.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/raw-string

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/tokens/raw-string.md

Document Version Independent Id

5737c986-9b06-9444-f7bc-893607d390d7

Article author

@BillWagner

Metadata

  • ID: 62bd57d5-0e7d-4355-0689-4b6b90ab4057
  • Service: dotnet-csharp
  • Sub-service: lang-reference

Related Issues

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions