Monday, May 20, 2019

c# - Can I escape a double quote in a verbatim string literal?



In a verbatim string literal (@"foo") in C#, backslashes aren't treated as escapes, so doing \" to get a double quote doesn't work. Is there any way to get a double quote in a verbatim string literal?



This understandably doesn't work:



string foo = @"this \"word\" is escaped";


Answer



Use a duplicated double quote.



@"this ""word"" is escaped";


outputs:



this "word" is escaped


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...