The easiest way to accomplish something like this is to use DateTime from the System namespace. First you build the string from user input, then try to create a valid DateTime instance from it using
DateTime.Parse(). This will return a valid object if successful, and otherwise, it will throw an exception. If you're not comfortable using exceptions, or wish to simplify the code, you can use
DateTime.TryParse() instead. This will accept an out DateTime parameter (semantically, this is just a ref parameter that doesn't need to be initialized prior to the call), and it will return a bool to indicate whether it succeeded. If it returns true, that means that the DateTime parameter has been filled in with valid information; otherwise, the string you provided could not be converted to DateTime.
There are also a whole host of
methods and
properties of DateTime that you can use to display or process the information however you like.