From the course: C# and .NET Essential Training
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Parsing dates - C# Tutorial
From the course: C# and .NET Essential Training
Parsing dates
- [Instructor] Earlier in the chapter, we saw how to parse strings into numerical data. The .net daytime class also makes it pretty easy to create daytime objects by parsing them from raw text. And if you've ever worked with dates and times you probably have encountered a scenario where you had to take some raw text and create an instance of a class from it. So let's open our code in the parse dates folder. Here in my code, similar to the numbers example we saw earlier I have an array of strings that represent various different forms of dates and times, and in some cases, both a date and a time. So once again, let use a loop to try and parse each of these strings into a date-time object. And just like with numbers, there's a parse method that throws an exception, but for the sake of brevity I'm just going to use the try parse function that returns a boolean indicating whether the parse succeeded. So what I'm going to write…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.