我已经尝试了各种方法,使用DateTime ToString
方法来呈现一个Apr '11格式的日期。文档中说'
被保留用于字符串字面量,所以我认为要显示单引号,应该使用''''
- 然而,不起作用。到目前为止,这是我尝试过的:
taskdata.Month.Start.ToString("MMM 'yy")
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
taskdata.Month.Start.ToString("MMM ''yy")
"Apr 09"
taskdata.Month.Start.ToString("MMM '''yy")
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
taskdata.Month.Start.ToString("MMM ''''yy")
"Apr 09"
taskdata.Month.Start.ToString("MMM \'yy")
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
taskdata.Month.Start.ToString("MMM '\''yy")
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
说真的,有什么秘诀吗?我不想使用字符串连接!