小编nov*_*ice的帖子

DateTime.TryParseExact()返回false

我有以下代码

public static void Main()
{
    DateTime D = new DateTime();
    D = DateTime.Now;

    string s1 = D.ToString("ddMMMMyyyy");
    Console.WriteLine(s1);

    Console.WriteLine(DateTime.TryParseExact(s1, "ddMMMyyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out D));
    Console.ReadKey();
}
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我意识到我正在犯的明显错误.

我转换DateTime.Now为自定义格式的字符串并尝试将其转换回来,但TryParseExact返回false.

c# datetime tryparse

-1
推荐指数
1
解决办法
323
查看次数

标签 统计

c# ×1

datetime ×1

tryparse ×1