Subscribe to danzar's Blog        RSS Feed
-----

Mega Project ideal list. - "Text" section / Check if Palindrome

Icon Leave Comment
I am taking the input from a text box then looping though it backward and creating the output string. after the loop is done I test the input text against the output text. If its true then its Palindrome.


 private void palindromeTest_bt_Click(object sender, RoutedEventArgs e)
        {
            if (palindromeInput_tb.Text != string.Empty)
            {
                string inputText = palindromeInput_tb.Text;
                string outputText = string.Empty;
                string letter = string.Empty;
                for (int i = inputText.Length - 1; i >= 0; i--)
                {
                    letter = inputText.Substring(i, 1);
                    outputText += letter;
                }
                if (inputText == outputText)
                { MessageBox.Show("Text is Palindrome"); }
                else
                { MessageBox.Show("Text is Not Palindrome"); }
            }
        }

0 Comments On This Entry

 

Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

July 2014

S M T W T F S
  12345
6789101112
13141516171819
20212223242526
272829 30 31  

Tags

    Search My Blog

    0 user(s) viewing

    0 Guests
    0 member(s)
    0 anonymous member(s)