.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!



Home >> Code Snippets >> Visual Studio >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

palindrome using C#.NET

Posted By:Syed Shakeer Hussain       Posted Date: February 17, 2009    Points: 10    Category: Visual Studio    URL: http://www.dotnetspark.com  
 

How to Write a Palindrome Programmer in 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();

  

 

        }

    }

}

 

Output:Enter a  string

       MADAM

       MADAM is palindrome



     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend