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.
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");
}
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;
}}
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;
}
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)
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;
}
}