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. Web Development
  3. ASP.NET
  4. How to avoid extra slashes and quotes???

How to avoid extra slashes and quotes???

Scheduled Pinned Locked Moved ASP.NET
databasetutorialquestion
6 Posts 3 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.
  • S Offline
    S Offline
    sinanju
    wrote on last edited by
    #1

    this is the entry in db <span id="Label1" style="font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;"> Now when i retrieve in source code string str = ds.Tables[0].Rows[1][1].ToString(); my str value contains the following value, where i found extra slashes with each quote, plus two extra quotes at the each end of the string "<span id=\"Label1\" style=\"font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;\">" how to get rid of these quotes and slashes?

    G N 2 Replies Last reply
    0
    • S sinanju

      this is the entry in db <span id="Label1" style="font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;"> Now when i retrieve in source code string str = ds.Tables[0].Rows[1][1].ToString(); my str value contains the following value, where i found extra slashes with each quote, plus two extra quotes at the each end of the string "<span id=\"Label1\" style=\"font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;\">" how to get rid of these quotes and slashes?

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

      How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows? That's the way you would write that string as a string constant, so that's how it's displayed. --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows? That's the way you would write that string as a string constant, so that's how it's displayed. --- b { font-weight: normal; }

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

        >>How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows? As i didn't get the desired result, so i stepped through the code looking at the watch window, and encounter these extra stuff. >>That's the way you would write that string as a string constant, so that's how it's displayed. sorry, i couldn't understand this.

        G 1 Reply Last reply
        0
        • S sinanju

          this is the entry in db <span id="Label1" style="font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;"> Now when i retrieve in source code string str = ds.Tables[0].Rows[1][1].ToString(); my str value contains the following value, where i found extra slashes with each quote, plus two extra quotes at the each end of the string "<span id=\"Label1\" style=\"font-family:Arial Narrow;font-size:XX-Large;font-weight:bold;font-style:italic;text-decoration: overline;\">" how to get rid of these quotes and slashes?

          N Offline
          N Offline
          NeverHeardOfMe
          wrote on last edited by
          #4

          If a string contains quotes - which are interpretted by the compiler as start/end of string - you have to escape them to tell it that they are part of the string and not delimiting it. Don't know about C, but in VB you can do this by by sinply doubling them - viz: Dim str As String = ds.Tables[0].Rows[1][1].ToString.Replace(Chr(34), Chr(34) & Chr(34)) (Since Chr(34) = the quote character) Hope that helps Phil

          S 1 Reply Last reply
          0
          • N NeverHeardOfMe

            If a string contains quotes - which are interpretted by the compiler as start/end of string - you have to escape them to tell it that they are part of the string and not delimiting it. Don't know about C, but in VB you can do this by by sinply doubling them - viz: Dim str As String = ds.Tables[0].Rows[1][1].ToString.Replace(Chr(34), Chr(34) & Chr(34)) (Since Chr(34) = the quote character) Hope that helps Phil

            S Offline
            S Offline
            sinanju
            wrote on last edited by
            #5

            This doesn't seem to help, im afraid. istead the following seems to be a step to the solution char[] strArr = ds.Tables[1].Rows[1][1].ToString().ToCharArray(); here strArr doesn't have the extra slashes or quotes, but now how to use this char array instead of string in my code. As casting it back to string will get me the string with extra slashes as before.

            1 Reply Last reply
            0
            • S sinanju

              >>How do you reckon that value looks like that? Are you singe stepping through the code and looking at the watch windows? As i didn't get the desired result, so i stepped through the code looking at the watch window, and encounter these extra stuff. >>That's the way you would write that string as a string constant, so that's how it's displayed. sorry, i couldn't understand this.

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

              sinanju wrote:

              >>That's the way you would write that string as a string constant, so that's how it's displayed. sorry, i couldn't understand this.

              An example: If you have this text: Text with "funny" characters. and put that in a string in the code, it would be written: string s = "Text with \"funny\" characters." This is the way that the watch windows show it. It does so to be able to show unprintable characters like line breaks. --- b { font-weight: normal; }

              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