问题描述
我有一个尊龙凯时的解决方案,在通过 visual studio 2015 运行时构建良好,但是当我从命令行运行时遇到错误
i have a solution which builds fine when running through visual studio 2015 but when i run from the command line i run into the error
错误 cs1056:此行出现意外字符$"
error cs1056: unexpected character '$' on this line
var cutofftextfragment = deadlinetime.deadline.minute == 0 ? $"{deadlinetime.deadline:htt}" : $"{deadlinetime.deadline:h:mmtt}"
deadlinetime.deadline 是一个 datetime 对象,代码将返回 xam/pm 或 x:xxam/pm
deadlinetime.deadline is a datetime object, the code will return either xam/pm or x:xxam/pm
我认为这是因为构建脚本没有使用 c#6.目前此脚本无法更改为使用 c# 6
i think this is occuring becuase the build script is not using c#6. at present this script cant be changed to use c# 6
如果是这种情况,任何人都可以帮我贬低代码以便它与 c# 5 一起使用
if this is the case, can anyone help me depreciate the code so it works with c# 5
推荐答案
$可以转换成string.format.
$ can be converted to string.format.
var cutofftextfragment = deadlinetime.deadline.minute == 0 ? string.format("{0:htt}",deadlinetime.deadline) : string.format("{0:h:mmtt}", deadlinetime.deadline);