Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. what is this used for --> @

what is this used for --> @

Scheduled Pinned Locked Moved C#
csharpphpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    karanba
    wrote on last edited by
    #1

    In some codes I saw @ character before string. I here that it is used in php sytax for breaking loops, but could not found any clue what it does in c#

    karanba

    E G 2 Replies Last reply
    0
    • K karanba

      In some codes I saw @ character before string. I here that it is used in php sytax for breaking loops, but could not found any clue what it does in c#

      karanba

      E Offline
      E Offline
      eggsovereasy
      wrote on last edited by
      #2

      Makes it so escape characters are skipped.

      string x = "What now man? \nWe are going to the store";
      Console.WriteLine(x);

      will output:

      What now man?
      We are going to the store

      whereas this:

      string x = @"What now man? \nWe are going to the store";
      Console.WriteLine(x);

      will output:

      What now man? \nWe are going to the store

      K 1 Reply Last reply
      0
      • E eggsovereasy

        Makes it so escape characters are skipped.

        string x = "What now man? \nWe are going to the store";
        Console.WriteLine(x);

        will output:

        What now man?
        We are going to the store

        whereas this:

        string x = @"What now man? \nWe are going to the store";
        Console.WriteLine(x);

        will output:

        What now man? \nWe are going to the store

        K Offline
        K Offline
        karanba
        wrote on last edited by
        #3

        :-O thaks much.

        karanba

        1 Reply Last reply
        0
        • K karanba

          In some codes I saw @ character before string. I here that it is used in php sytax for breaking loops, but could not found any clue what it does in c#

          karanba

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          A @ delimited string has the double quote as only escape code. These declarations are equivalent: string a = "A string with \"quotes\" and a backslash: \\ in it."; string b = @"A string with ""quotes"" and a backslash: \ in it.";

          --- b { font-weight: normal; }

          W 1 Reply Last reply
          0
          • G Guffa

            A @ delimited string has the double quote as only escape code. These declarations are equivalent: string a = "A string with \"quotes\" and a backslash: \\ in it."; string b = @"A string with ""quotes"" and a backslash: \ in it.";

            --- b { font-weight: normal; }

            W Offline
            W Offline
            WILLIAM MAIN
            wrote on last edited by
            #5

            I also use it for creating multiline strings string sql = @" SELECT * FROM TABLE WHERE THIS=@THAT ";

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups