在 C# 中,您可以使用 \ 忽略特殊字符:
string myString = "this is a \" string";
这将作为一个完整的字符串工作......在VB中,这样做是行不通的......
任何人都知道相当于\来忽略VB的特殊字符?
在 C# 中,您可以使用 \ 忽略特殊字符:
string myString = "this is a \" string";
这将作为一个完整的字符串工作......在VB中,这样做是行不通的......
任何人都知道相当于\来忽略VB的特殊字符?
VB.NET 将引号加倍,如下所示:
Dim myString As String = "this is a "" string"
对于引号,将引号加倍:
"This is a ""quote"""
对于其他一切,你运气不好,不得不求助于 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. 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