C# 二叉搜索树 - 堆栈溢出 - 调试
我是继 C++ 之后学习 C# 的新手。 VS2010。
尝试调试我的代码时,我在“locals”框架中遇到了奇怪的空行。 在我盯着这些空行几秒钟后,调试器就退出了。
请查看:http://pastebin.com/KZbfy8JF
谢谢。
我花了至少 3 个小时寻找解决方案并摆弄代码,但无济于事。
I am a newbie learning C# after C++. VS2010.
Trying to debug my code, I come across weird empty lines in the "locals" frame.
The debugger just quits after a few seconds of me staring at these empty lines.
Please check it out: http://pastebin.com/KZbfy8JF
Thanks.
I've spent at least 3 hours looking for solutions and playing around with code to no avail.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Value
属性 getter 和 setter 是无限递归的 - 将它们更改为:The
Value
property getter and setters are infinitely recursive - change them to this:已经回答了(值获取/设置),但这里有一个提示:
在 VS.NET 中,按 CTRL+ALT+E 打开 异常 对话框(根据您在 VS.NET 中选择的配置文件,它也可能位于“调试”->“异常”下)。这可以让您在引发某些异常类型时中断,而不是完全堆栈展开和程序最终崩溃。
对于“公共语言运行时异常”,选中“抛出”复选框,单击“确定”,然后运行程序。程序的执行将在异常点停止,这应该使它更加明显。
就您而言,该程序会破坏您的财产。要查看更多信息,请打开调用堆栈窗口(调试-> Windows->调用堆栈或 CTRL+ALT+C) 查看完整堆栈,您会发现您的属性几乎是其中唯一的东西。
Already answered (Value get/set) but here is a tip:
In VS.NET, press CTRL+ALT+E to open the Exceptions dialog (depending on your profile selected in VS.NET, it may be under Debug->Exceptions as well). This lets you break when certain exception types are thrown, as opposed to the full stack unwinding and the program ultimately crashing.
For "Common Language Runtime Exceptions" check the "Thrown" checkbox, hit OK, then run your program. The execution of your program will stop at the point of exception, which should make it much more obvious.
In your case, the program breaks on your property. To see more, open the Call Stack wndow (Debug->Windows->Call Stack or CTRL+ALT+C) to see the full stack and you'll see your property is just about the only thing in it.
一般来说,堆栈溢出意味着您正在递归而不返回。但我不明白你在哪里这样做。我要做的就是在几个战略位置插入 Console.WriteLine 语句,以查看执行哪些行以及执行频率。例如,在 Insert 的开头和内部循环中。这应该为您(和我们;)提供更多信息。
Ok generally, stack overflow would mean that you're recursing without going back. I don't see however where you do that. What I'd do would be to insert a Console.WriteLine statement in a few strategic places to see which lines are executed and how often. For example, on the beginning of Insert, and in the inner loop. This should give you (and us ;) a bit more information.