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<str.Length-2;j++)
{
s[j]=str[k];
k++;
}
return ispalindrome(s);
}
else
{
return 0;
}
}
}
}