Results 1 to 9 of 9

Thread: Where's the explanation @ [Resolved]

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Talking 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.

  2. #2
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552

    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...

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I was just trying to understand this code. I've been put into a C# project... no choice but to work with it.

  4. #4
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    Dunno if I posted a help for you. If not, I'm sorry but Good Luck mend.

  5. #5

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    It helped, duh. That explains the [resolved] that mysteriously got added...

  6. #6
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    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).

  7. #7
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877
    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 :

  8. #8
    Fanatic Member brown monkey's Avatar
    Join Date
    Jun 2004
    Location
    Cebu
    Posts
    552
    Nice.

  9. #9

    Thread Starter
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    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
  •  



Click Here to Expand Forum to Full Width