开发者

how to make this date valid in c#

i want to make my date valid 16/10/2010

if i parse compiler give me error at runtime. how i c开发者_开发技巧an parse it.

it is formated as Day/Month/Year


You'd parse it with something like:

DateTime dt = DateTime.ParseExact(text, "dd/MM/yyyy",
                                  CultureInfo.InvariantCulture);

Use DateTime.TryParseExact if this is user input which may well be invalid without it representing a bug in your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜