Results 1 to 7 of 7

Thread: The @ symbol in front of some strings

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    65

    The @ symbol in front of some strings

    I see this @ character a lot in front of C# strings. I searched the documentation online but coult not come up with the page that explains this symbol. What is it used for?

  2. #2
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099

    Re: The @ symbol in front of some strings

    It gives you the literal string, not the escaped string.
    Code:
    strS1 = @"c:\windows\system32\";
    strS2 = "c:\\windows\\system32\\";
    Would be the same thing.

  3. #3
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: The @ symbol in front of some strings

    What does that mean? You mean,It makes no difference?
    Godwin

    Help someone else with what someone helped you!

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: The @ symbol in front of some strings

    yep exactly, just saves the fingers a little
    but ...
    You can also use the / slash instead of the \
    eg:
    VB Code:
    1. [COLOR=Blue]private void[/COLOR] button1_Click([COLOR=Blue]object[/COLOR] sender, System.EventArgs e)
    2.         {
    3.             [COLOR=Blue]string[/COLOR] path = "C:/Documents and Settings/den/My Documents/My Pictures/twins.jpg";
    4.             System.Diagnostics.Process.Start( path );
    5.         }
    Last edited by dynamic_sysop; Sep 10th, 2005 at 02:02 AM.
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: The @ symbol in front of some strings


    Hey Dynamic...
    Since when was this possible?
    This is Amazing...I remember this didnt work long ago...I wonder when both slashes meant the same.This is Awesome.Thanks so much for this info.
    Godwin

    Help someone else with what someone helped you!

  6. #6
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: The @ symbol in front of some strings

    Its general practice to always use @"" when you are doing paths. Using normal "" way is generally reserved for inline markup like "Hello\nWorld".
    I don't live here any more.

  7. #7
    Fanatic Member uniquegodwin's Avatar
    Join Date
    Jul 2005
    Location
    Chennai,India
    Posts
    694

    Re: The @ symbol in front of some strings

    Roger that...
    Godwin

    Help someone else with what someone helped you!

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