Cool piece of code

This is just a hacked up version of a professionally written code to check if a string is palindrome.

Recursion is our friend as much as it is our foe.

[[kish@MiAmor ~]$ cat propalin.cs
 using System;

class Palindrome{

     static void Main(string[] args){





		Console.WriteLine("Not a Palindrome");


     public static bool CheckPalindrome( string s ){

               return CheckPalindrome( s, 0, s.Length - 1 );


     private static bool CheckPalindrome( string s, int left, int right ){

                       if ( left >= right )

                            return true;
                 		       else if ( s[left] != s[right] )

                            return false;

                            return CheckPalindrome( s, left + 1, right - 1 );



2 thoughts on “Cool piece of code

  1. animal facts says:

    The main thing i’m enjoying while reading your blog is the way you write, you are a really charismatic person and your posts are wonderful, keep it up!

  2. krisk says:

    Happy that you enjoy my posts.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: