When I change the following C# string
string xml="xmlns:qtpRep=\"http://www.mercury.com/qtp/ObjectRepository\""
into
string xml=@"xmlns:qtpRep=\"http://www.mercury.com/qtp/ObjectRepository\""
I get compiler error: ;expected
How can I express the literal double quotes inside a string starting with @ ?
You double the double quotes instead of using a backslash:
(See MSDN for more details.)
Although in this case it’s not clear why you want a verbatim string literal anyway… and for XML attributes it’s generally simpler just to use single quotes:
I’m also bound to say that if you’re creating XML strings yourself, you’re probably Doing It WrongTM. Use an XML API instead 🙂