Multiline string literals in C#: how to declare a string with line breaks?
Hello everyone! I'm a beginner C# developer, switched from Python, and I've encountered a problem that seems very inconvenient to me.
\nIn Python, I could easily create multiline strings using triple quotes:
\ntext = """This is a multiline string.\nIt can contain line breaks.\nAnd it's very convenient."""\nBut in C#, I can't find a direct analog. When I try to write a long SQL query, JSON, or just text with line breaks, I get compilation errors or have to use workarounds.
\nHere's an example of what I want to do:
\nstring query = "SELECT * \nFROM Users \nWHERE Age > 18";\nObviously, you can't write it like that — the compiler complains. I know about string concatenation and @-strings (verbatim strings), but they don't solve the problem.