Datetime.parse不起作用 [英] Datetime.parse is not working
本文介绍了Datetime.parse不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi,
DateTime.Parse is not working.
I have written follwing code.
What I have tried:
DateTime.Parse("29/12/2016", "en");
same code is working for other culture. only for english its giving follwing error.
String was not recognized as a valid DateTime.</pre>
谢谢......
Thanks......
推荐答案
根据 DateTime.Parse Method(String,IFormatProvider)(System) [ ^ ] ,第二个参数是 IFormatProvider [ ^ ]。
试试
According to DateTime.Parse Method (String, IFormatProvider) (System)[^], the second parameter is IFormatProvider[^].
Try
using System;
using System.Globalization;
public class Program
{
public static void Main()
{
DateTime dt = DateTime.Parse("29/12/2016", new CultureInfo("en-GB"));
Console.WriteLine(dt);
}
}
这篇关于Datetime.parse不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文