ARTICLE

Palindrome in C# GUI

Posted by Adarsh Acharya Articles | .NET Assemblies March 13, 2011
Software to check weather the word ,sentence,number are same when read from backward and forward eg Racecar,malayalam etc uses array ,first index and last index this is the one and only GUI version of palindrome available on-line checking word and sentences
Reader Level:
Download Files:
 

You can enter any word, number, sentence(without punctuation marks) and this will give the output yes or no.

preview.jpg

//my palindrome code

//please enter the input sentence without any symbols like ,.? etc
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Palindrome
{
    public partial class Form1 : Form
    {
        int i, startchar, lastchar;
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            //So that everything in lower case
            //this will avoid the error of showing Racecar as not a palindrome as r is diff from R to C#
            //RaCeCar is same as RaceCar
            string low = textBox1.Text.ToLower()
            //so that panlindrome sentence can also be chaecked
            //this will remove space in a sentence Race car int racecar
            low = low.Replace(" ", "");
            //char[] character = new char[anynumber/limit]
            char[] character = new char[100];
            character = low.ToCharArray();
            startchar = 0
            lastchar = character.Length - 1;
            while (startchar < lastchar)
            {
                if (character[startchar] == character[lastchar])
                {
                    startchar++;
                    lastchar--;
                }
                else
                {
                    //u can also use messagebox
                    label1.Visible = true;
                    label1.Text = "It is not a Palindrome";
                    button1.Text = "Try Again";
                    textBox1.Focus()
                    //so that the application does not get closed after braking the loop and u can try again
                    //this is used in the if statement after breaking the loop
                    i = 2;
                    break;
                }
            }
            if (i < 2)
            {
                label1.Visible = true;
                label1.Text = "It is a Palindrome";
                button1.Text = "Try Another";
                textBox1.Focus();
            }
            else
            {
                //the value is reset to 0
                //or else the application will get stucked
                i = 0;
            }
        }
    }
}

uses array ,first index and last index 

this is the one and only GUI version of palindrome available on-line  checking word and sentences

Read Comments in C# for more details

Time pass project by me 

@D@R$|-|

Login to add your contents and source code to this article
post comment
     

mmmmmmmmmmm

Posted by Praveen S Apr 23, 2012

mmmmmmmmmmm

Posted by Praveen S Apr 23, 2012

i have added a small intro about this project as demanded by mentors @D@R$|-|

Posted by Adarsh Acharya Jan 26, 2012

It's a great effort keep it up but you should write some description about the code in brief thanks.

Posted by Amit Maheshwari Nov 28, 2011

Nice coding Adarsh but I think if you also write some theory, its good to understand for the reader...

Posted by Manish Tewatia Mar 16, 2011
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.