Palindrome in C# GUI

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$|-|

Up Next
    Ebook Download
    View all
    Learn
    View all