-1
如何string
年转换为DateTime
格式?解析从字符串年DATETIME
我的代码:
// click button
string a = "2014";
DateTime b = DateTime.Parse(a);
MessageBox.Show(b.ToString());
如何string
年转换为DateTime
格式?解析从字符串年DATETIME
我的代码:
// click button
string a = "2014";
DateTime b = DateTime.Parse(a);
MessageBox.Show(b.ToString());
你可以尝试这样的事情
var year = int.Parse("2014");
DateTime dateTime = new DateTime(year, 1, 1);
Console.WriteLine(dateTime.ToString());
错误信息 '其他信息:年,月和日参数描述一个未表示的DateTime.' – marshall
我已经更新了我的答案 –
感谢解决方案@BRAHIM Kamel – marshall