开发者

how to make this date valid in c#

开发者 https://www.devze.com 2023-01-20 14:25 出处:网络
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.

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

精彩评论

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

关注公众号