SIGN UP MEMBER LOGIN:    
ARTICLE

Palindrome in C# GUI

Posted by Adarsh Acharya Articles | C# 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
share 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
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor