[Csharp]
Using System;
Using System. Collections;
Namespace CStack
{
Class Program
{
Static void Main (string [] args)
{
CStack alist = new CStack ();
String ch;
String word = "Shanghai tap water comes from the sea ";
Bool isPalindrome = true;
For (int x = 0; x <word. Length; x ++)
{
Alist. Push (word. Substring (x, 1 ));
}
Int pos = 0;
While (alist. Count> 0)
{
Ch = alist. Pop (). ToString ();
If (ch! = Word. Substring (pos, 1 ))
{
IsPalindrome = false;
Break;
}
Pos ++;
}
Console. WriteLine (isPalindrome );
}
}
Public class CStack
{
Private int p_index;
Private ArrayList list;
Public CStack ()
{
List = new ArrayList ();
P_index =-1;
}
Public int Count
{
Get {return list. Count ;}
}
Public void Push (object item)
{
List. Add (item );
P_index ++;
}
Public object Pop ()
{
If (0> p_index)
{
Return null;
}
Object obj = list [p_index];
List. RemoveAt (p_index );
P_index --;
Return obj;
}
Public void Clear ()
{
List. Clear ();
P_index =-1;
}
Public object Peek ()
{
If (p_index <0)
{
Return null;
}
Return list [p_index];
}
}
}