简体   繁体   English

ToShortDateString()不可用?

[英]ToShortDateString() not available?

I'm coding in a console app in C# and neither of the following lines of code are compiling: 我正在C#控制台应用程序中进行编码,以下两行代码均未编译:

var x = DateTime.Now.ToShortDateString()
var y = DateTime.Now.Date.ToShortDateString()

Any idea what the problem might be? 知道可能是什么问题吗?

I think you are forgetting the semicolon at the end. 我认为您忘记了最后的semicolon
Think of the ; 想想; as please, if you dont say please at the end, your code with not work, 顺便说一句,如果您最后不说请,您的代码将无法正常工作,
c# is a polite language. C#是一种礼貌的语言。

var x = DateTime.Now.ToShortDateString();
var y = DateTime.Now.Date.ToShortDateString();

Console.WriteLine(x);
Console.WriteLine(y);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM