Wednesday 2 June 2021

Check given string is palindrome or not

 public bool IsPalindrome(string value)  

        {    bool result = true;  

            if (string.IsNullOrEmpty(value))  

                return false;  

            _title = value.ToLower().Trim();  

            var min = 0;  

            var max = _title.Length - 1;  

            while (max >= 0)  

            {    if (value[min] == value[max])  

                {  min++;  max--; }  

                else  {  return false; }  }  

  

             return result; 

No comments:

Post a Comment