C# DateTime.TryParseExact 格式转换问题
var value = "30.04.2022";
try
{
DateTimeFormatInfo dateTimeFormatInfo = new CultureInfo("zh-CN", false).DateTimeFormat;
if (!DateTime.TryParseExact(value.ToString(),"dd.MM.yyyy", dateTimeFormatInfo,DateTimeStyles.None, out DateTime dateTime))
{
value = null;
}
else
{
value = dateTime;
}
}
catch (Exception ex)
{
value = null;
}
https://blog.csdn.net/weixin_34187822/article/details/86153618