Here's an example of using DateTime.TryParse() method in C# to parse a string into a DateTime object while handling any exceptions that may arise:
main.cs278 chars11 lines
The TryParse() method returns a boolean value indicating whether or not the parsing operation was successful. If successful, the parsed DateTime object is output to the console as a string. If unsuccessful, an error message is output instead.
gistlibby LogSnag