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