January 2012
Intermediate to advanced
396 pages
8h 16m
English
With the two methods, Reverse() and EqualCollections(), finding whether a sequence is palindromic or not becomes a single line of code. Let's see how:
string word = "rotor";
bool isPalindrome =
Algorithms.EqualCollections(word.ToCharArray(), Algorithms.Reverse(word.ToCharArray()));
string status = word + " is ";
if (isPalindrome)
status += "Palindromic";
else
status += "Not Palindromic";
status.Dump();This method can work with any type of collection.
The
Reverse() method is used to reverse ...
Read now
Unlock full access