|
-
Nov 25th, 2004, 02:36 AM
#1
Where's the explanation @ [Resolved]
PHP Code:
this.Controls.Add(new LiteralControl(@"</head>
<body topmargin=0 leftmargin=0 >
") );
What's the @?
Last edited by mendhak; Nov 25th, 2004 at 03:25 AM.
-
Nov 25th, 2004, 02:56 AM
#2
Fanatic Member
Re: Where's the explanation @
@ 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...
-
Nov 25th, 2004, 03:25 AM
#3
I was just trying to understand this code. I've been put into a C# project... no choice but to work with it.
-
Nov 25th, 2004, 03:29 AM
#4
Fanatic Member
Dunno if I posted a help for you. If not, I'm sorry but Good Luck mend.
-
Nov 25th, 2004, 03:33 AM
#5
It helped, duh. That explains the [resolved] that mysteriously got added...
-
Nov 25th, 2004, 09:16 PM
#6
PowerPoster
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).
-
Nov 25th, 2004, 10:22 PM
#7
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
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Nov 25th, 2004, 10:33 PM
#8
-
Nov 29th, 2004, 03:30 AM
#9
Very nice, I didn't nkow this.
Another point for C#, eh?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|