using System;
namespace DataStructure
{
/// <summary>
/// Class
/// </summary>
public class Stack//棧類
{
private int count=
private Node first=null;//定義首結點
public bool Empty
{
get
{
return(first==null);
}
}
public int Count
{
get
{
return count;
}
}
public object Pop()//入棧
{
if(first==null)
{
throw new InvalidOperationException(
}
else
{
object temp=first
first=first
count
return temp;
}
}
public void push(object o)//出棧
{
first=new Node(o
count++;
}
public Stack()
{
//
// TODO: 在此處添加構造函數邏輯
//
}
}
class Node //結點類
{
public Node Next;
public object Value;
public Node(object value):this(value
public Node(object value
{
Next=next;
Value=value;
}
}
}
From:http://tw.wingwit.com/Article/program/ASP/201311/21883.html