rbwhitaker / CSharpPlayersGuideEarlyAccess

A place to track issues with the C# Player's Guide for patches and future editions
19 stars 0 forks source link

Raw string literals #645

Closed rbwhitaker closed 1 year ago

rbwhitaker commented 2 years ago

A type of string literal that has no escaping whatsoever but can contain quotes and backslashes and other things.

You need at least three double-quote marks. What if you want triple quotes in your text? Quadruple quotes! You can add as many quote marks as you need for your text.

This also eliminates leading whitespace in an intuitive way. The end quote is the thing that decides how much whitespace you get, so you can move that back to get as much leading whitespace as you want.

If you put a $ at the front, you can still get string interpolation, and single curly braces still get interpolated. The number of dollar signs is the number of curly braces that you need to do interpolation.

rbwhitaker commented 1 year ago

This is now covered in the new chapter on strings.