Results 1 to 6 of 6

Thread: C# program for palindrome

  1. #1
    Join Date
    Nov 2009
    Posts
    83

    C# program for palindrome

    Hi All,

    From few days I have been trying to write C# program for palindrome, But didn't get any success in it. I have used "Reverse" function it this programm but it's giving error when try to run this code.
    Array.Reverse(stringName);
    string sr = new string(stringName);
    Do you know the C# program for palindrome then please share with me.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,949

    Re: C# program for palindrome

    Hi , we can use "Reverse" function in c sharp to find out the given string is palindrome or not. Pleas see the below C sharp example I have used used the "Reverse" in it:
    string str = "aslc";
    char[] str = str.ToCharArray();

    Array.Reverse(str);

    string tyu = new string(str);

    if (str == tyu)
    {
    MessageBox.Show("String is palindrome");
    }
    else
    {
    MessageBox.Show("String is not palindrome");
    }

  3. #3
    Join Date
    May 2008
    Posts
    2,015

    Re: C# program for palindrome

    I don't think that you have tried the below c sharp code:
    private bool
    CheckPalindm(string myString)
    {
    string strevis="";
    foreach char h in mystr
    {
    strrevs= h + strevis;
    }

    if (strevis==mystr)

    return true;
    else
    {
    return false;

    }}

  4. #4
    Join Date
    Apr 2008
    Posts
    2,010

    Re: C# program for palindrome

    Hi friend,

    I have below code for verify the palindrome number in the C sharp language:

    bool paln (string strg)
    {
    if (strg== null || strg.Length == 0)
    {
    return false;
    }
    for (int a = 0; a < strg.Length / 2; a++)
    { if (strg[i] != strg[strg.Length - 1 - a])
    { return false; }
    }
    return true;
    }

  5. #5
    Join Date
    May 2008
    Posts
    2,302

    Re: C# program for palindrome

    Hello,

    Please use the reverse function in your c# code. Please go through the below code and implement in your palindrome program code, make some changes in the variable as per your need:
    string stringDem="";
    foreach char gtr;
    {
    stringDem= gtr + stringDem;
    }

    if (stringDem==gtr)

  6. #6
    Join Date
    Oct 2005
    Posts
    2,394

    Re: C# program for palindrome

    See if something below can help you:
    public bool Palndn()
    {
    string stringPal = "plad";
    int j= stringPal .Length;
    string ht= "";
    for (int k = j - 1; k >= 0; k--)
    {

    ht= ht+ stringPal [k];
    }
    if (ht== stringPal )
    {
    return true;
    }
    else
    {
    return false;
    }

    }

Similar Threads

  1. Replies: 3
    Last Post: 28-01-2011, 12:57 PM
  2. Windows DEP program continuously closes the MSN mail program
    By Charioteer in forum Windows Software
    Replies: 4
    Last Post: 19-10-2010, 11:52 AM
  3. How to extract Palindrome from a given sentence?
    By Baazigar in forum Software Development
    Replies: 4
    Last Post: 25-01-2010, 08:13 PM
  4. how to write program on palindrome in java?
    By Linoo in forum Software Development
    Replies: 3
    Last Post: 26-11-2009, 04:19 PM
  5. Program to determine a word or a phrase is a palindrome in C/C++
    By Lambard in forum Software Development
    Replies: 4
    Last Post: 09-12-2008, 06:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •