[英]What is the Visual Basic (VB) equivalent of \ in C#?
In C# you can use \\ to ignore the special characters: 在C#中,您可以使用\\来忽略特殊字符:
string myString = "this is a \" string";
that would work as one complete string... in VB, doing that does not work... 这将作为一个完整的字符串......在VB中,这样做不起作用......
Anyone know the equivalent of \\ to ignore special characters for VB? 任何人都知道相当于\\忽略VB的特殊字符?
VB.NET将这样的引号加倍:
Dim myString As String = "this is a "" string"
For the quotation, double the quote: 对于报价,报价翻倍:
"This is a ""quote"""
For everything else, you're out of luck and have to resort to Chr 对于其他一切,你运气不好,不得不求助于Chr
"This is a string with a " & Chr(10) & "line-feed"
You can use Regex.Unescape
for using the c# style escape sequences if you want to use it for other special characters besides the double quotes. 如果要将其用于除双引号之外的其他特殊字符,则可以使用Regex.Unescape
来使用c#样式转义序列 。 To escape the double quotes use the (already mentioned) ""
("double double quotes"). 要转义双引号,请使用(已提及) ""
(“双引号”)。
Console.WriteLine(Regex.Unescape("Test\tTest"))
Console.WriteLine(String.Format(Regex.Unescape("{0}:\t {1}"), a, x))
Ciao! 再见! Stefan 斯特凡
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.