How to avoid extra slashes and quotes???
-
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?
-
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?
-
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; }
>>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.
-
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?
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
-
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
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.
-
>>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.
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; }