Is there a heredoc notation for strings in C#, preferably one where I don\'t have to escape anything (including double quotes, which are a quirk in verbatim strings
As others have said, there isn't.
Personally I would avoid creating them in the first place though - I would use an embedded resource instead. They're pretty easy to work with, and if you have a utility method to load a named embedded resource from the calling assembly as a string (probably assuming UTF-8 encoding) it means that:
No, there is no "HEREDOC" style string literal in C#.
C# has only two types of string literals:
@
-quoted: doublequotes need to be escaped by doublingString literals are of type
string
and can be written in two forms, quoted and@
-quoted.
Well even though it doesn't support HEREDOC's, you can still do stuff like the following using Verbatim strings:
string miniTemplate = @"
Hello ""{0}"",
Your friend {1} sent you this message:
{2}
That's all!";
string populatedTemplate = String.Format(miniTemplate, "Fred", "Jack", "HelloWorld!");
System.Console.WriteLine(populatedTemplate);
Snagged from: http://blog.luckyus.net/2009/02/03/heredoc-in-c-sharp/