Skip to content

[New article]: Lang Comment on Raw String Literals?ย #43758

@EdLichtman

Description

@EdLichtman

Proposed topic or title

Language Syntax in Raw String Literals

Location in table of contents.

No response

Reason for the article

This is a neat feature that seems very useful, but is completely undocumented. I only know about it from a post on Reddit that I read.

Article abstract

To enhance your code-writing experience, you can include //lang={language} to allow your IDE to highlight your Raw String Literals in the format of your language of choice. What this means is, if you include a comment above your Raw String Literal, and it matches the format specified, you get custom language highlighting.

e.g.:

public class MyExample {
    //lang=json
    public static readonly string JsonString = """
                                               {
                                                  "statusCode": 400,
                                                  "error": "Bad Request",
                                                  "message": "The request was invalid."
                                               }
                                               """;
}

Seems to result in the quotes text appearing like:
Image

Relevant searches

"Lang"
"Block Quotes"
"Lang Comments Block Quotes C#"
"Lang Comments Raw String Literals C#"
"Raw String Literals C# Json"


Document Details

โš  Do not edit this section. It is required for learn.microsoft.com โžŸ GitHub issue linking.


Associated WorkItem - 479362

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions