What's the @?PHP Code:
this.Controls.Add(new LiteralControl(@"</head>
<body topmargin=0 leftmargin=0 >
") );
Printable View
What's the @?PHP Code:
this.Controls.Add(new LiteralControl(@"</head>
<body topmargin=0 leftmargin=0 >
") );
@ deminishes the escape characters treatment. Strings in C-based languages contains (or not) escape characters like "\n" or "\t" as newline and tab, respectively. Now to be safe, if you want your string to be as exactly as what you want, put @ before it...
But I don't see why you put @ on your string. Usually, the "\" is the issue. Like you want to print "\n" and not newline, put @"\n" or "\\n"... Cause printing a backslash is "\\" and not just "\" because of the reason as I said earlier, "\" is the issue of being an escape character.
Hope this helps...
I was just trying to understand this code. I've been put into a C# project... no choice but to work with it. :(
Dunno if I posted a help for you. If not, I'm sorry but Good Luck mend. :)
It helped, duh. That explains the [resolved] that mysteriously got added... :D
The @ sign does a little bit more than treating it as a string literal which ignores the backslash constants.
It also allows you to throw your string across lines like the example being shown. This is a big deal when you maybe want to write readable code like sql statements (or xml):
string strSQLStmt =
@"SELECT MyTableID,
Column1,
Column2,
Column3,
Column4,
Column5,
Column6,
Column7
FROM MyTable
WHERE MyTableID= @MyTableID";
Many people don't realize what it actually does unless they find it in code somewhere (it is getting more popular though).
I use @ to treat string as literal but didnt know you could use it to write multi-lined string.Quote:
Originally posted by hellswraith
The @ sign does a little bit more than treating it as a string literal which ignores the backslash constants.
Nice one HW :thumb:
Nice. :)
Very nice, I didn't nkow this.
Another point for C#, eh? :D