使用Visual Studio可以很好地构建项目,但是从命令行失败 [英] Project builds fine with Visual Studio but fails from the command line
问题描述
我有一个在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);
这篇关于使用Visual Studio可以很好地构建项目,但是从命令行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!