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.

String manipulation

String manipulation

- [Instructor] In this example, we'll take a look at how to manipulate string content. And we'll be using these sample strings that I defined here in my code. If we open up the code file, you'll see that I have some strings here at the top of the source code in the Manipulation folder. So let's go ahead and get started. So remember that strings are sequences of characters, and we can obtain information, such as the length of a string, using the length property. So let's go ahead and try that first. So we'll write out str1 dot Length. Or we can access individual characters using bracket notation to index into the string. So for example, I can access the 14th character in str1. And remember this is a zero-based index, so 14 actually gives me the 15th character. And in fact, we can iterate over the content of a string just like we can with any other sequence or collection of data. So for example, I can use a foreach loop.…

Contents