C#日期格式化正在丢失斜杠分隔符 [英] C# date formatting is losing slash separators
本文介绍了C#日期格式化正在丢失斜杠分隔符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我在C#中执行此操作:
If I do this in C#:
Console.WriteLine(DateTime.Now.ToString("ddd M/dd/yy"));
我希望输出如下:
Wed 6/15/11
但实际上输出:
Wed 6 15 11
为什么斜线消失?有没有办法防止这种情况,并以期望的格式输出日期?
Why are the slashes disappearing? Is there a way to prevent this and have the date outputted in the expected format?
推荐答案
Console.WriteLine(DateTime.Now.ToString("ddd M/dd/yy", CultureInfo.InvariantCulture));
Console.ReadLine();
尝试以上
这篇关于C#日期格式化正在丢失斜杠分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文