Hi All,
Could some one explain me the difference between the 2 lines below.
string sql = @"SELECT columnname " +
@"FROM tablename " +
@"WHERE ID = '" + settingId + "' ";
string sql = "SELECT columnname " +
"FROM tablename " +
"WHERE ID = '" + settingId + "' ";
Does '@' in the first statement makes any difference?
Question on C# strings
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Jun 3, 2009, 6:41 PM EDT
if there is ' / ' then you should use @ before string
other wise not
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Jun 4, 2009, 12:39 PM EDT
The @ symbol tells the string constructor to ignore escape characters and line breaks. The following two strings are therefore identical:
string p1 = "\\\\My Documents\\My Files\\";
string p2 = @"\\My Documents\My Files\";