DQbJA{7{P{7B?Phiyiyh^RmKyhyhmK%PUb@PhpU'yhhyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyDQbJA{7{P{7B?Phiyiyh^RmKyhyh{|wRRmKyh{wRRmKyhmK%PUpw(b@PhpU'yhhyypyyyyyyyywyyyyyyy(yyylyaAaeCEBAeCsXWCB| 9VCBZBZCCB 966VCC-

Palindrome.` Palindromes can be read in both directions. A palindrome has the same letters on both ends of the string. It is a form of word puzzle.`An example palindrome.` The string "civic" is a palindrome, but "perls" is not. How can you determine if a string is a palindrome in the C# language?`Example.` This program introduces the IsPalindrome boolean method. In the method body, we determine the minimum and maximum indexes inside the string. `Then: `We scan from the minimum forward, and from the maximum backward, at the same time.`If the characters are different, we return false. If we are done scanning, we return true.`Bool `bool`Notes, method.` Instead of converting the input string with ToLower, which would require an allocation, we check the lowercased versions of all the characters. This makes it faster. `If your input strings are always lowercase, it would be better to remove the char.ToLower transformations.`char.ToLower `char-tolower`Notes, continued.` The method throws an exception if the parameter string is null. If the parameter string is empty, it will consider that a palindrome. `Null Strings `null-string`Exception `exception`Sentences.` This program is the same as the simpler palindrome method except for some small changes. The important change is inside IsPalindrome. There are two additional while-loops. `While `while`If a char is determined to be a non-letter non-digit character, we begin skipping forward or backward to one that should be checked.`So: `Punctuation and spaces do not affect the palindromicity of a phrase. Sentences are handled correctly.`char.IsLetterOrDigit `char-isletterordigit`Performance.` What is the advantage of using two sub-loops to skip forward and back? This approach means you do not need to allocate any new strings. `You can check the original string data without converting it. Avoiding string allocations makes a program faster.`Info: `A slower approach strips all spaces and punctuation from the source string. Then, you could use the simpler palindrome method.`A summary.` We introduced a simple C# method that tests for palindromes. Many palindromes are composed of multiple words and have spaces and punctuation. These can all be tested.

234 33333 {4 2/3<3> 2/3Determines whether the 3 is a palindrome. 2/3</3> 2433bool 4IsPalindrome4(3 3) 2{ 223min30; 223max33.L3 - 1; 223 (true) 22{ 2223min > max) 222{ 22223 true; 222} 222char a33[min]; 222char b33[max]; 2223char.ToLower(a) != char.ToLower(b)) 222{ 22223 false; 222} 222min++; 222max--; 22} 2} 232{ 223[] 3 = 22{ 222"civic", 222"deified", 222"deleveled", 222"devoved", 222"dewed", 222"Hannah", 222"kayak", 222"level", 222"madam", 222"racecar", 222"radar", 222"redder", 222"refer", 222"repaper", 222"reviver", 222"rotator", 222"rotor", 222"sagas", 222"solos", 222"sexes", 222"stats", 222"tenet", 222"Dot", 222"Net", 222"Perls", 222"Is", 222"Not", 222"A", 222"Palindrome", 222"" 22}3223 (3 333) 22{ 2223"{0}3{1}", 3, IsPalindrome(3)); 22} 2} } 4 civic3True deified3True deleveled3True devoved3True dewed3True Hannah3True kayak3True level3True madam3True racecar3True radar3True redder3True refer3True repaper3True reviver3True rotator3True rotor3True sagas3True solos3True sexes3True stats3True tenet3True Dot3False Net3False Perls3False Is3False Not3False A3True Palindrome3False 3True4 33333 {4 2/3<3> 2/3Determines whether the 3 is a palindrome. 2/3</3> 2433bool 4IsPalindrome4(3 3) 2{ 223min30; 223max33.L3 - 1; 223 (true) 22{ 2223min > max) 222{ 22223 true; 222} 222char a33[min]; 222char b33[max];4 2223Scan 3ward 3a 3 invalid. 22243 (!char.IsLetterOrDigit(a)) 222{ 2222min++; 22223min > max) 2222{ 222223 true; 2222} 2222a33[min]; 222}4 2223Scan backward 3b 3 invalid. 22243 (!char.IsLetterOrDigit(b)) 222{ 2222max--; 22223min > max) 2222{ 222223 true; 2222} 2222b33[max]; 222} 2223char.ToLower(a) != char.ToLower(b)) 222{ 22223 false; 222} 222min++; 222max--; 22} 2} 232{ 223[] 3 = 22{ 222"A man, a plan, a canal: Panama.", 222"A Toyota. Race fast, safe car. A Toyota.", 222"Cigar? Toss it3a can. It is so tragic.", 222"Dammit, I'm mad!", 222"Delia saw I was ailed.", 222"Desserts, I stressed!", 222"Draw, O coward!", 222"Lepers repel.", 222"Live not on evil.", 222"Lonely Tylenol.", 222"Murder 3a jar of red rum.", 222"Never odd or even.", 222"No lemon, no melon.", 222"Senile felines.", 222"So many dynamos!", 222"Step on no pets.", 222"Was it a car or a cat I saw?", 222"3 is not a palindrome.", 222"Why are you reading this?", 222"This article is not useful.", 222"...", 222"...Test" 22}3223 (3 333) 22{ 2223"{0}3{1}", 3, IsPalindrome(3)); 22} 2} } 4 A man, a plan, a canal: Panama.3True A Toyota. Race fast, safe car. A Toyota.3True Cigar? Toss it3a can. It is so tragic.3True Dammit, I'm mad!3True Delia saw I was ailed.3True Desserts, I stressed!3True Draw, O coward!3True Lepers repel.3True Live not on evil.3True Lonely Tylenol.3True Murder 3a jar of red rum.3True Never odd or even.3True No lemon, no melon.3True Senile felines.3True So many dynamos!3True Step on no pets.3True Was it a car or a cat I saw?3True 3 is not a palindrome.3False Why are you reading this?3False This article is not useful.3False 3= True ...Test3False4

">@checks for palindromic stringschecks for palindromic sentences