How can I create a string which contains the following:
<Object type="System.Windows.Forms.Form
Use an escape character for the quote:
string temp = "<Object type=\"System.Windows.Forms.Form"
See the msdn article for more examples: http://msdn.microsoft.com/en-us/library/h21280bw.aspx
Edit
Correct link for C#: C# programming guide
You have two choices, depending on the remainder of the text you want to place into the string:
use the escape character \
within the double-quoted string for any double-quote marks, as the other answers have suggested.
string s = "<Object type=\"System.Windows.Forms.Form";
use the string-@ form, which avoids processing the \
(such as in path names like C:\Temp\Myfile.txt
), and then double the double-quote:
string s = @"<Object type=""System.Windows.Forms.Form";
See also: http://msdn.microsoft.com/en-us/library/362314fe(v=vs.71).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With