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


namespace Palindrome
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] str = new char[10];
            Console.WriteLine("Enter The Palindrome Series(Max 10 Characters)");
            str = Console.ReadLine().ToCharArray();
            Console.WriteLine(CheckPalindrome(str));
        }
        private static bool CheckPalindrome(char[] mystring)
        {
            int startchar;
            int lastchar;
            startchar=0;
            lastchar=mystring.Length -1;
            while(startchar<lastchar)
            {
                if(mystring[startchar]==mystring[lastchar])
                {
                    startchar++;
                    lastchar--;

                }
                else
                {
                    return false;

                }
            }
            return true;

         }

        }
     }

how to hold the screen of the console ? As i am writing Console.ReadLine() in the code to hold the screen , but there is no response and i am getting the same result the program get exit automatically..

Please HElp

Recommended Answers

All 3 Replies

Add Console.ReadKey(); after line 16 of your code.

You need another Console.ReadLine entry afteryour WriteLine

This line

char[] str = new char[10];

You can get rid of everything after str as you replace what was created when you assign the ReadLine() result to it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.