As a reminder, in the previous lecture we learned about the string data type, where a string is just a sequence of unicode characters. In this lecture, we'll explore some more interesting ways to extract information from a string. So, what might we want to do with a string? Well, we might want to convert it to a value type and we saw that in the previous lecture, and we saw that in the previous course, anytime we parse, we're converting a string into a value type. We might want to find the location of a particular character in a string. So, if we were processing comma separated values strings, strings where the values are separated by commas, we might want to find where the commas are. We might want to extract a piece of the string into a different string and that would also apply if we were processing a comma separated values string, and we might want to do any of many other things. And if you discover you need something else to do string processing, you just go read the string documentation and find what you need. Okay. Let's go do some string processing in code. Here's what we're going to do for our string processing. We're going to read in a comma separated value string, we're going to find the comma location in that string, we'll extract data from the string once we know the comma location, and then we'll print the data that we've extracted. So we'll start by reading in that CSV string. And notice that because we expect the user to enter this information in a particular format, we should tell them what that format is. Now we'll read that into a string, I'll call it the CSV string. And the next thing we need to do is find the comma location and the way you discover which string method you need to use to do this is you go read the string documentation and find the one that will give us the location of something we're looking for. And I already know the answer to that, and it is the index of method. So I'm going to put the comma location into an int variable because it's an index into the string and so it has to be a whole number. And then I do this, I say CSV string, and then I call the index of method on that string. And as you can see from this hop that popped up, I provide a character that I'm looking for, and the character I'm looking for is a comma. So now that we have done this, you should go do an in-video quiz about the method that we just discovered here. Okay. I'm going to actually output the comma location here just as a debugging thing to make sure that we're actually extracting the comma location properly. And I'll say, Bob comma, 0.1 percent. The comma location is three. And if that seems strange to you remember we start at zero. So, B is zero and O is one and B is two, so the comma is our index three in the string. Now you might wonder what happens if there is no comma in the string and it turns out that the answer is, we get negative one. So, negative one means the character you were looking for did not appear in the string. So, let's extract the name and percent from the string. So I want to get the name first, and the name will certainly be a string, and it's a piece of the CSV string. And so, now we need a method that lets us get a piece of a string. So we can look up the string class and take the first hit that we get and scroll down to the method and find the one we need. And I'll just go there quickly because I know what it is, the method that we want is substring. And as you can see there are two versions of substring, one where we provide a single integer, Int32 just means int, and this one starts at a specified character position and goes to the end of the string and we definitely do not want that one because name is at the beginning of the string. So we don't want to start somewhere and go all the way to the end of CSV string. For this other overload of substring, we provide two integers and it starts at the first one and has a specified length. And that's the one we need to extract the name. So you should go doing in-video quiz about what the documentation just told us. And now we can actually use it, by saying CSV substring, and we want to use the substring overload that takes two arguments. The first one is the location at which we want to start and we want to start at character zero because we know strings start at character zero. And now we want to provide the length. And one of the thing that's great about zero-based indexing, is we can just provide comma location as the length of the substring. And that works because if you think about it, the example I did with Bob comma, the comma location is at three and starting at zero, we want to grab exactly three characters, the B, the O and the B. So, this works great with zero-based indexing. And let's actually make sure that we're extracting the name properly. So I'll say, Bob is getting smart is 0.2 percent. And there we go. We've extracted Bob correctly. Add that blank line. And now we need to extract the percent. So, we can say, we're going to put it in the percent, and we know we want to substring out of our comma separated value string. This time we need to start at a particular location and go to the end of the string. And that's the other overload of the substring method but we don't want to start at comma location, we want to start at comma location plus one because we don't want to grab the comma as part of the substring, we're grabbing for percent. This won't actually compile successfully, done here in the error window. I expanded that error that says you can't convert a string to a float. We've seen that problem before and we even know how to solve it because we can just do float.Parse to parse this into our percent. And I'm going to hit enter there so we can see the whole line of code here, I'm all zoomed in so you can see the code better. But we can use float.Parse just like we've used int.parse, and there's even a bull.parse and a short.parse, and lots of ways that we can parse from a string into a value type. So the last thing we should do is print out the value of the percent we've extracted, and when we run, Bob is really smart now, he's got 101.3 percent. And as you can see, we've extracted the name and the percent properly from our CSV string. To recap, in this lecture we saw how we can use some of the methods provided by the string class to process strings in useful.