Reputation:
i want to make my date valid 16/10/2010
if i parse compiler give me error at runtime. how i can parse it.
it is formated as Day/Month/Year
Upvotes: 0
Views: 357
Reputation: 1503954
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.
Upvotes: 5