Click to See Complete Forum and Search --> : Where's the explanation @ [Resolved]
mendhak
Nov 25th, 2004, 01:36 AM
this.Controls.Add(new LiteralControl(@"</head>
<body topmargin=0 leftmargin=0 >
") );
What's the @?
brown monkey
Nov 25th, 2004, 01:56 AM
@ 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...
mendhak
Nov 25th, 2004, 02:25 AM
I was just trying to understand this code. I've been put into a C# project... no choice but to work with it. :(
brown monkey
Nov 25th, 2004, 02:29 AM
Dunno if I posted a help for you. If not, I'm sorry but Good Luck mend. :)
mendhak
Nov 25th, 2004, 02:33 AM
It helped, duh. That explains the [resolved] that mysteriously got added... :D
hellswraith
Nov 25th, 2004, 08:16 PM
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).
Danial
Nov 25th, 2004, 09:22 PM
Originally posted by hellswraith
The @ sign does a little bit more than treating it as a string literal which ignores the backslash constants.
I use @ to treat string as literal but didnt know you could use it to write multi-lined string.
Nice one HW :thumb:
brown monkey
Nov 25th, 2004, 09:33 PM
Nice. :)
mendhak
Nov 29th, 2004, 02:30 AM
Very nice, I didn't nkow this.
Another point for C#, eh? :D
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.