如何使用C#将DateTime对象转换为仅包含日期的字符串?

Bar*_*hen 1 c# asp.net

看似简单.我需要将DateTime对象转换为没有时间戳的字符串.

这给了我日期和时间.我无法弄清楚如何获得约会.

        startDate = Convert.ToString(beginningDate);
Run Code Online (Sandbox Code Playgroud)

输出:10/1/2011 12:00:00 AM

我需要它:10/1/2011作为一个字符串

任何帮助表示赞赏.

And*_*ker 8

查看 .ToShortDateString()

string startDate = beginningDate.ToShortDateString();
Run Code Online (Sandbox Code Playgroud)

还检查了.ToString方法上DateTime,需要一个格式字符串.例如:

string startDate = beginningDate.ToString("d");
Run Code Online (Sandbox Code Playgroud)

示例: http ://ideone.com/tpyZy