views:

114

answers:

2

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!

A: 

basic syntax is same

string csharp;    // C#
string cPlusPlus; // C++

see following for better insight

string class (C++) and string class (C#)

Asad Butt
+2  A: 

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
JaredPar