Reversing a String : String Insert Replace « String « C# / CSharp Tutorial






class Palindrome
{
  static void Main()
  {
      string reverse, palindrome;
      char[] temp;

      System.Console.Write("Enter a palindrome: ");
      palindrome = System.Console.ReadLine();

      reverse = palindrome.Replace(" ", "");
      reverse = reverse.ToLower();
      temp = reverse.ToCharArray();

      System.Array.Reverse(temp);
      if(reverse == new string(temp))
      {
          System.Console.WriteLine("\"{0}\" is a palindrome.",palindrome);
      }
      else
      {
          System.Console.WriteLine("\"{0}\" is NOT a palindrome.",palindrome);
      }
  }
}








5.15.String Insert Replace
5.15.1.String Inserting
5.15.2.Replace string
5.15.3.Replace characters
5.15.4.Replace substring
5.15.5.Reversing Characters
5.15.6.Reversing a String