top | item 23042019

(no title)

apk-d | 5 years ago

I wish that's how C# handled it! There are verbatim string literals that support newlines, but in practice, most of the time I see people stick to regular string concatenation because it ruins code indentation/alignment. That's how Rider chooses to refactor code when you insert a newline as well. Multi-line verbatim strings begin to get useful around the point where you should be probably loading your text from some resource instead of embedding it in the source.

discuss

order

ygra|5 years ago

There's plenty of contexts where the extra indentation doesn't matter, though. And C#'s verbatim strings, at least when it comes to multiple lines, have the benefit of being extremely predictable in what ends up in the string (everything, including whitespace). They also have other uses that Java doesn't even address, like not interpreting escape sequences inside the string.

I'm not sure you can really compare them. They're two different features with fairly different uses, it's just that one or two of those uses somewhat overlap.

apk-d|5 years ago

They're comparable in the sense that I'm guessing C# is unlikely to get yet another string declaration syntax, so we're stuck with what we've got. Regarding predictability I definitely agree, but good syntax highlighting would help with that.