![](/img/trans.png)
[英]what is the equivalent of visual basic withevents and handles in C#
[英]What is the Visual Basic (VB) equivalent of \ in C#?
在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"
如果要將其用於除雙引號之外的其他特殊字符,則可以使用Regex.Unescape
來使用c#樣式轉義序列 。 要轉義雙引號,請使用(已提及) ""
(“雙引號”)。
Console.WriteLine(Regex.Unescape("Test\tTest"))
Console.WriteLine(String.Format(Regex.Unescape("{0}:\t {1}"), a, x))
再見! 斯特凡
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.