问题
I'm referring to the syntax for writing strings in code, including multiline strings and verbatim strings.
(Context: I'm working on a tool that scans code, and it's important to determine when tokens are inside a string.)
Thanks!
回答1:
Here's a quick breakdown between languages
- Managed C++: Supports string literals much in the way that vanilla C,C++ or C# does. That is strings are designated by " and allow for character escape sequences in the middle via a \.
- C#: Supports normal string literals (essentially same syntax as Managed C++) and verbatim string literals. Verbatim string literals start with
@"
and do not support character escape sequences (with the exception of "" which designates a single "). They can span multiple lines and all whitespace is significant - VB.Net: Strings are delimited by "'s and no escape sequences are supported
回答2:
basic syntax is same
string csharp; // C#
string cPlusPlus; // C++
see following for better insight
string class (C++) and string class (C#)
来源:https://stackoverflow.com/questions/2464444/what-are-the-differences-in-string-literals-between-c-visual-basic-net-and-ma