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 searching - C# Tutorial
From the course: C# and .NET Essential Training
String searching
- [Instructor] All right, let's finish up this chapter by looking at some of the .NET APIs for searching string content. So I'll open up my program file here in my editor. And once again, I have a test string that I'm going to use to try out some of the string searching functions. And I'll start by using one of the most common ones which is the Contains function. All right. Let's console that WriteLine. And what I'm going to write out is teststr and I'm going to call the Contains function on it to see if it contains the word "fox." All right now, by default, the Contains function takes the casing of the letters into account. So you can see that this is lowercase "fox" and this is an uppercase "Fox." So this would normally return false, but we can specify that it should ignore the letter case with an instance of the stringComparison class. So let me add that for comparison. You can see the two side by side. So…
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.