Friday, January 11, 2008

C# @ string meaning.

And now for a little string manipulation:

string initXML = @"<?xml version=""1.0"" ?><request company=""gnc"" auth=""{0}"" unit=""{1}"" code=""{2}"" />";

initXML = String.Format(initXML, authCode, location, passCode);

The difference between a regular and verbatim string expression:
























Regular literal

Verbatim literal

Result

"Unplug1dot6"

@"Unplug1dot6"

Unplug1dot6

"Backslash: \\"

@"Backslash: \"

Backslash: \

"Quote: \""

@"Quote: """

Quote: "

"CRLF:\r\nPost CRLF"

@"CRLF:
Post CRLF"

CRLF:
Post CRLF

No comments: