"Rory Becker" <ro********@newsgroup.nospamwrote in message
news:3a**************************@news.microsoft.c om...
Hello Mike Gleason jr Couturier,
Why do I see a @ preceding strings in code examples?
What does the @ do?
I believe it is a c# sytax that prevents the compiler otherwise
interpreting
certain characters as escape codes.
for example
-------------------------------------------------------------
string SomeString = "\n"; //This produces an enter keystroke
string OtherString = @"\n"; //This produces a string containing the
backslash
and 'n' characters.
-------------------------------------------------------------
Correct and in addition a string preceded with @ can split across lines:-
string someSQL = @"
SELECT a.Field1, a.Field2
FROM ATable a
INNER JOIN BTable b ON b.ID = a.ID
WHERE b.Field3 = 15"
The down side is that " need to be duplicated as "" e.g.:-
string someXML = @"<root thing=""x"" />"
--
Anthony Jones - MVP ASP/ASP.NET