From the course: Learning C#

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

String parsing

String parsing - C# Tutorial

From the course: Learning C#

String parsing

- [Instructor] In this example, we're going to see how to parse the contents of a string into native C# data types and again, this is a pretty common operation that programs have to perform. Your program might be given something like numerical data in string format and you need to convert it into an actual number. So let's take a look in the Parsing folder. Let's open the code up. So here in my code, I have a few string variables defined that represent different number types. So I've got an integer, a floating point number, a number with a comma in it for thousands, and then the same thing but with a decimal value. So the different basic data types in C# provide a parse function that you can use to parse a string into that particular type. And you can also specify that certain formats are allowed as well. So let's start off with a simple integer example. Now, the reason I'm going to put this inside a try catch…

Contents