Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



C# program for palindrome

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 22-12-2009
Member
 
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.
Quote:
Array.Reverse(stringName);
string sr = new string(stringName);
Do you know the C# program for palindrome then please share with me.

Reply With Quote
  #2  
Old 22-12-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
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:
Quote:
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");
}
Reply With Quote
  #3  
Old 22-12-2009
Member
 
Join Date: May 2008
Posts: 2,007
Re: C# program for palindrome

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

if (strevis==mystr)

return true;
else
{
return false;

}}
Reply With Quote
  #4  
Old 22-12-2009
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: C# program for palindrome

Hi friend,

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

Quote:
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;
}
Reply With Quote
  #5  
Old 22-12-2009
Member
 
Join Date: May 2008
Posts: 2,291
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:
Quote:
string stringDem="";
foreach char gtr;
{
stringDem= gtr + stringDem;
}

if (stringDem==gtr)
Reply With Quote
  #6  
Old 22-12-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: C# program for palindrome

See if something below can help you:
Quote:
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;
}

}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "C# program for palindrome"
Thread Thread Starter Forum Replies Last Post
“This program is using by another program” error message in windows 7 SchuRacer Operating Systems 3 28-01-2011 01:57 PM
Windows DEP program continuously closes the MSN mail program Charioteer Windows Software 4 19-10-2010 12:52 PM
How to extract Palindrome from a given sentence? Baazigar Software Development 4 25-01-2010 09:13 PM
how to write program on palindrome in java? Linoo Software Development 3 26-11-2009 05:19 PM
Program to determine a word or a phrase is a palindrome in C/C++ Lambard Software Development 4 09-12-2008 07:23 PM


All times are GMT +5.5. The time now is 05:44 AM.