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.
精彩评论