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)?
Here document (Heredoc) is an input or file stream literal that is treated as a special block of code. This block of code will be passed to a command for processing. Heredoc originates in UNIX shells and can be found in popular Linux shells like sh, tcsh, ksh, bash, zsh, csh.
Heredoc's are equivalent to a double quoted string. That means any variables in the string will get substitued for their respective values. We could rewrite the double quoted string example above as a heredoc:- $foo = 'bar'; echo <<<EOT Hello $foo Goodbye! EOT; // Output:- // Hello bar // Goodbye!
Heredoc is one of the ways to store or print a block of text in PHP. The data stored in the heredoc variable is more readable and error-free than other variables for using indentation and newline.
The heredoc syntax is a way to declare a string variable. The heredoc syntax takes at least three lines of your code and uses the special character <<< at the beginning.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With