我的项目中的NullReferenceException [英] NullReferenceException in my project

查看:63
本文介绍了我的项目中的NullReferenceException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有纸牌游戏,但是我正在努力工作,有时会迷迷糊糊,但是过了一会儿我才知道问题出在哪里,但是在这种情况下,我只是束手无策.

我必须将链接发布到我的文件中,否则代码将太长,因为存在许多不同的类.

这是链接

http://www.4shared.com/rar/AQvIkAQr/LetItRide.html?refurl=d1url [ ^ ]

要得到该错误,您需要做的就是单击开始"按钮,然后单击"25-500投注范围"按钮,然后单击任何筹码按钮,然后单击交易"按钮,这就是您应该获得例外的时间. div class ="h2_lin">解决方案

您可能在代码中使用了一些变量,该变量为null,未正确处理就意味着对null进行异常处理.进行调试和检查.这些链接将对您有所帮助:-

http://www.csharp-station.com/Tutorials/lesson15.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/ms173163.aspx [ ^ ]

字符串 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

http://www.4shared.com/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:-

http://www.csharp-station.com/Tutorials/lesson15.aspx[^]

http://msdn.microsoft.com/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆