ليس لدي اجابات
How to work with verbatim string literals?
When I try to define a verbatim string literal, escaped double quotes ("") are turned to \" in the real string and I cannot use mystring.replace("\"","""") to turn \" to ".
Developer technologies | Visual Studio | Other
Developer technologies | C#
4 answers
Sort by: Most helpful
-
مبروكة فؤاد بيبي محمد الزنياني 0 Reputation points
2023-05-29T22:21:34.1766667+00:00 -
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2023-05-30T01:14:51.21+00:00 If I read
John "Henry" Adams
from a text file usingvar result = File.ReadAllText("textfile1.txt").Replace("\"", "\\\""); Debug.WriteLine(result);
We get
John \"Henry\" Adams
Unsure if this is what you want, you need to provide a reproducible example.
-
Anonymous
2023-05-30T08:00:40.0666667+00:00 Hi @captain power , Welcome to Microsoft Q&A.
From your updated info, it looks like you don't need to use replace.
You just need to use
@
correctly to accomplish your needs.var mystring = @".....'.....""......"".....'"; Console.WriteLine(mystring);
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
-
Lamia Elshahat Eldesoky 76 Reputation points
2023-05-30T21:27:19.8933333+00:00 The same answer