📄 stack.cs
字号:
using System;
namespace StackSample
{
public class Stack
{
private Node first = null;
private int count = 0;
public bool Empty
{
get
{
return (first == null);
}
}
public int Count
{
get
{
return count;
}
}
public object Pop()
{
if (first == null)
{
throw new InvalidOperationException ("不能从空堆栈进行Pop操作");
}
else
{
object temp = first.Value;
first = first.Next;
count --;
return temp;
}
}
public void Push(object o)
{
first = new Node(o, first);
count++;
}
private 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;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -