DateTime tryParse问题 [英] DateTime tryParse problem

查看:83
本文介绍了DateTime tryParse问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不知道出了什么问题。我有问题解析字符串到datetime。我使用这种方法:

I really don't know what is wrong. I have problem to parse string to datetime. I use this method :

DateTime dt;
string date = "14.5.2011";
bool b = DateTime.TryParse(date, out dt);
Console.WriteLine("bool = " + b);

它告诉我总是假的。你知道为什么吗?我从来没有遇到过这个问题。

It show me always false. Do you know why? I have never had problem with this.

感谢您的回答。

推荐答案

当字符串采用这种格式时,它显示tru ...

it shows tru when a string is in this format ...

string date = "yyyy.M.dd";

so

string date = "2011.5.14";

我仍然不知道该怎么做。 ..

I still dont know how to do it ...

也许tryParse有多种格式或者......

maybe tryParse with many formats or ...


这篇关于DateTime tryParse问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆