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. Store Double Quote in string Variable

Store Double Quote in string Variable

Scheduled Pinned Locked Moved C#
question
4 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.
  • M Offline
    M Offline
    M Riaz Bashir
    wrote on last edited by
    #1

    Hi, Please let me know how may I store follow string value into string variable ? string myValue = "aa[a"a]aa"; Thank you in advance

    D S OriginalGriffO 3 Replies Last reply
    0
    • M M Riaz Bashir

      Hi, Please let me know how may I store follow string value into string variable ? string myValue = "aa[a"a]aa"; Thank you in advance

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      use a backslash to escape the quote

      string myValue = "aa[a\"a]aa";

      Dave
      Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

      1 Reply Last reply
      0
      • M M Riaz Bashir

        Hi, Please let me know how may I store follow string value into string variable ? string myValue = "aa[a"a]aa"; Thank you in advance

        S Offline
        S Offline
        Simon_Whale
        wrote on last edited by
        #3

        string d = "this is a open quote \" and this is a \" close Quote";

        Every day, thousands of innocent plants are killed by vegetarians. Help end the violence EAT BACON

        1 Reply Last reply
        0
        • M M Riaz Bashir

          Hi, Please let me know how may I store follow string value into string variable ? string myValue = "aa[a"a]aa"; Thank you in advance

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          To add to what Davey and Simon have said, '\' is an "escape" character, which tells the compiler that the following character is a special, rather than a standard character. A '\' followed by double quote is a double quote character rather than the end of the string, and other sequences have different meaning, such as \\ for a '\' character, \n for a newline and \t for a tab. You can also use:

          string myValue = @"aa[a""a]aa";

          The '@' turns off recognition of the '\' as a special, allowing you to type a single '\' character if you are entering a path:

          string mypath = "D:\\Temp\\myfile.txt";

          Or

          string mypath = @"D:\Temp\myfile.txt";

          When you use a '@' prefix, you use tqo double quote characters together to insert a single double quote character in the string.

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          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