c#本质论第三版,源代码跑不起,怎么回事啊?

yy412179149 yy412179149 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
第11章开头的代码如下,首先是没有Main函数入口,我自己加了一个,然后运行程序就一直嘟嘟嘟嘟
响,求大神指点啊,谢谢!
namespace AddisonWesley.Michaelis.EssentialCSharp.Chapter11.Listing11_02
{
using System;
using System.Collections;

public class Program
{
// ...

public void Sketch()
{
Stack path = new Stack();
Cell currentPosition;
ConsoleKeyInfo key; // New with C# 2.0

do
{
// Etch in the direction indicated by the
// arrow keys that the user enters.
key = Move();

switch (key.Key)
{
case ConsoleKey.Z:
// Undo the previous Move.
if (path.Count >= 1)
{
currentPosition = (Cell)path.Pop();
Console.SetCursorPosition(
currentPosition.X, currentPosition.Y);
Undo();
}
break;

case ConsoleKey.DownArrow:
case ConsoleKey.UpArrow:
case ConsoleKey.LeftArrow:
case ConsoleKey.RightArrow:
// SaveState()
currentPosition = new Cell(
Console.CursorLeft, Console.CursorTop);
path.Push(currentPosition);
break;

default:
Console.Beep(); // New with C#2.0
break;
}

}
while (key.Key != ConsoleKey.X); // Use X to quit.

}

private static ConsoleKeyInfo Move()
{
//fill in method.
return new ConsoleKeyInfo();
}

private static void Undo()
{
//fill in method.
}
}

public struct Cell
{
readonly public int X;
readonly public int Y;
public Cell(int x, int y)
{
X = x;
Y = y;
}
}

}
...全文
评论 12
收藏 已收藏
分享
返回顶部
yy412179149
C# 111,129 成员 642,540 内容