here i write a program to check the given string is plindrome or not by using recursion function.iam getting exception here please solve it.
using System;
using System.Collections.Generic;using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace prime
{
class Program
{
public static void Main()
{
Program p = new Program();
Console.WriteLine("enter a string");
string s1 = Console.ReadLine();
//string s1 ="madam";
char[] str = s1.ToCharArray();
Console.WriteLine( p.ispalindrome(str));
Console.ReadLine();
}
int ispalindrome(char[] str)
{
char[] s = new char[str.Length - 2];
if(str.Length==0||str.Length==1)
return 1;
if(str[0]==str[str.Length-1])
{
int k = 1;
for(int j=0;j
s[j]=str[k];
k++;
}
return ispalindrome(s);
}
else
{
return 0;
}
}
}
}

Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 23, 2016, 6:38 AM EDT
Joginder BangerRank #360 · 7K reputationPosted Aug 23, 2016, 12:14 AM EDT
Ajay MalikRank #752 · 3.1K reputationPosted Aug 23, 2016, 1:08 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Aug 23, 2016, 1:28 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Aug 23, 2016, 5:44 AM EDT