当你用VS写东西多了,是不是发现你离开VS的时候连函数名都拼不对了?(当然这是VS的优点,太智能了。)

用记事本也可以写C#程序哟。

首先新建一个记事本,命名为AutoMem.txt; //自定义的内存管理

添加代码如下(实现自定义的栈):

 

using System;
public class Stack
{
private Node first=null;
public bool Empty()
{
if (first== null)
{
return true;
}
else
{
return false;
}
}
//进栈
public object Pop()
{
if(first==null)
{
throw new Exception("Cannot Pop from an empty Stack!");
}
else
{
object temp=first.Value;
first=first.Next;
return temp;
}
}
//出栈
public void Push(object o)
{
//注意只要一句话哦
first=new Node(o,first);
}

//定义一个结点类型的数据结构
public class Node
{
public Node Next; //下一个结点
public object Value;// 结点的值
public Node(object value):this(value,null)
{

}
public Node(object value,Node next)
{
Value=value;
Next=next;
}
}


}
class Test
{
static void Main()
{
Stack s = new Stack();
for (int i = 0; i < 10; i++)
{

s.Push(i);
}
while (!s.Empty())
{
Console.WriteLine(s.Pop());
}
}
}

先修改记事本的扩展名,即把Automem.txt修改为Automem.cs;

然后在Ms-Dos窗口中输入:

csc/out::AutoMem.exe Automem.cs   //生成。exe文件

然后输入:AutoMem.exe 

运行结果:

9

8

7

6

5

4

3

2

1

0.。。。

什么感觉呢?哈哈。

C# 还可以这样玩。。。。