我的项目中的NullReferenceException

编程入门 行业动态 更新时间:2024-10-26 16:32:06
本文介绍了我的项目中的NullReferenceException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有纸牌游戏,但是我正在努力工作,有时会迷迷糊糊,但是过了一会儿我才知道问题出在哪里,但是在这种情况下,我只是束手无策. 我必须将链接发布到我的文件中,否则代码将太长,因为存在许多不同的类. 这是链接 www.4shared/rar/AQvIkAQr/LetItRide.html?refurl=d1url [ ^ ] 要得到该错误,您需要做的就是单击开始"按钮,然后单击"25-500投注范围"按钮,然后单击任何筹码按钮,然后单击交易"按钮,这就是您应该获得例外的时间. div class ="h2_lin">解决方案

您可能在代码中使用了一些变量,该变量为null,未正确处理就意味着对null进行异常处理.进行调试和检查.这些链接将对您有所帮助:- www.csharp-station/Tutorials/lesson15.aspx [ ^ ] msdn.microsoft/en-us/library/ms173163.aspx [ ^ ] 针对null异常处理的结果4,450,000个c#

NullReferenceException可能在您对null变量调用方法时发生.例如:

字符串 s = 空; 如果(s.equals(...))// 这里会引发NullReferenceException ...

在示例中,您已经在string变量中调用了equals方法,但是该变量实际上并未指向任何对象.是null. 正如SAKryukov在其评论中所写的那样,只需对其进行调试,就可以逐步进行操作,并找出将哪个变量设置为null. 请参阅堆栈跟踪以标识引发异常的点.然后,您只需要检查该点周围的几条线即可.

I have card game , and I am working on it and sometimes I get stumbled, but after awhile I figure out what the problem is, but in this case I am just helpless. I have to post the link to my file, otherwise the code will be too long, because there''s a lot of different classes. This is is the link www.4shared/rar/AQvIkAQr/LetItRide.html?refurl=d1url[^] What you have to do to get the error is click Start button, then click 25-500 bet range button, and then click on any chip button and after that click Deal button, and that''s when you should get the exception.

解决方案

you may be using some variable in your code which is null and its not handled properly means the null exception handling. Do debugging and check. Thess links will be helpful to you:- www.csharp-station/Tutorials/lesson15.aspx[^] msdn.microsoft/en-us/library/ms173163.aspx[^] 44,500,000 results on null exception handling c#

NullReferenceException can happen when you call a method on a null variable. For example:

string s = null; if (s.equals(...)) // NullReferenceException is thrown here ...

In the example, you have called equals method in a string variable, but the variable actually doesn''t point to any object. It''s null. As SAKryukov has wrote in his comment, just debug it, go step by step, and find out which variable is set to null. See the stack-trace to identify the point which the exception is thrown. Then you will have to check just few lines around that point.

更多推荐

我的项目中的NullReferenceException

本文发布于:2023-07-25 09:10:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1209011.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:项目   NullReferenceException

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!