在搜索如何在 String.Format 中转义单引号时,我在SO:Escaping single quote in String.Format() 中找到了答案
不过对于VB来说似乎有所不同。我测试过了,确实C#需要
string s = DateTime.Now.ToString("MMM d \\'yy 'at' H:mmm");
而VB需要
Dim s As String = Now.ToString("MMM d \'yy 'at' H:mmm")
为什么 C# 需要双反斜杠,而 VB 需要单反斜杠?对于 C# 用户来说,这可能是一个有点愚蠢的问题,但是虽然我可以阅读 C#,但我不习惯编写它。