且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

无法将类型'string'隐式转换为'System.DateTime'

更新时间:2023-02-18 21:22:02

string input = "21-12-2010"; // dd-MM-yyyy    
DateTime d;
if (DateTime.TryParseExact(input, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out d))
{
    // use d
}