using system; namespace datastructure { /// <summary> /// class1 的摘要说明。 /// </summary> public class stack//栈类 { private int count=0; 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("can not pop from an empty stack;"); } else { object temp=first.value; first=first.next; count--; return temp; } } public void push(object o)//出栈 { first=new node(o,first); count++; } public stack() { // // todo: 在此处添加构造函数逻辑 // } } class node //结点类 { public node next; public object value; public node(object value):this(value,null){} public node(object value,node next) { next=next; value=value; } } }