Resources » Code Snippets » Console Applications

Palindrome using C#


Posted Date: 17-Feb-2009  Last Updated:   Category: Console Applications    
Author: Member Level: Gold    Points: 8



Palindrome using C#.net

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string str=string .Empty ;

Console.WriteLine("Enter a String");

string s = Console.ReadLine();

int i = s.Length;
//we can get the Length of string by using Length Property

for (int j=i -1; j >= 0; j--)
{
str = str + s[j ];
}
if (str == s)
{


Console.WriteLine(s + " is palindrome");


}
else
{
Console.WriteLine(s + " is not a palindeome");
}

Console.WriteLine(str);

Console.Read();


}
}
}


Did you like this resource? Share it with your friends and show your love!

Responses to "Palindrome using C#"
Author: Miss Meetu Choudhary    17 Feb 2009Member Level: Gold   Points : 1

Please do provide description too along with you code to receive good responses and recognition points



Thanks and Regards
Meetu Choudhary
Editor



Author: Joe Kidd    23 May 2011Member Level: Bronze   Points : 0
This is my version - it returns all palindromes in the input sentence:



Scratches.cs.txt
Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Subscribe to Subscribers
    Awards & Gifts
    Talk to Webmaster Tony John

    Online Members

    More...
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India