How to Write Quotation Marks in an ASP.NET String
Quotation marks in ASP.NET denote the beginning and end of a string value when used as code. Any text within the quotes is considered a part of the string. When you want to use actual quote marks for grammatical purposes in a string, you must use the escape character, which is the backslash character. The escape character tells the compiler that the quote is literal and does not end or begin a string value.
Instructions
-
-
1
Click the Windows "Start" button and select "All Programs." Click "Microsoft .NET Framework," then click "Visual Studio" to open the editor. Open your project file after VS finishes loading.
-
2
Double-click the ASP.NET code file in "Solution Explorer" to open the editor. If you do not already have a string defined, add the following code to create a blank string:
string mystr = string.Empty;
-
-
3
Add a quote character to the string's value. The following code shows you how to add a quote to the string value:
mystring = "The user said, \"Hello World.\"";
The previous code adds quotes around "Hello World" without terminating the string or causing a syntax error.
-
1