From the course: Learning C#
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Solution: Palindrome - C# Tutorial
From the course: Learning C#
Solution: Palindrome
(upbeat music) - [Instructor] Let's review my solution for the palindrome challenge. Now, your solution might look different from mine and that's okay. The point here is to learn different ways of solving a given problem. So the function takes a string argument, which is the string that we are going to test for being a palindrome. So I have a local variable named teststr, which will be used to perform the palindrome test. So first, my code converts the string to uppercase since one of the rules we had to follow was that we need to ignore the case of the input string. So by converting the string to uppercase, I can just compare each character in the string directly. Then I use a string builder to strip out all the punctuation and white space from the input string. This loop processes each character in the string and adds it to the string builder if it is not punctuation or white space. And I check that by using the…
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.