对象引用参考未设置问题 [英] Object reference refernce not set problem

查看:83
本文介绍了对象引用参考未设置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


即时通讯使用包含文本框的第一个类的公共属性从另一个类中设置了textbox.text属性,但是它抛出的对象引用未设置为对象的实例...任何解决方案?


i m setting textbox.text property from another class using public property of first class that contains the textbox but it is throwing object reference not set to an instance of object...any solution?

推荐答案

在将文本框(和表单)设置为值之前,请确保已实例化该文本框(和窗体).
Make sure the textbox (and form) has actually been instantiated before setting it to a value.


您的第一类未初始化.
所以这个属性不是一流的


当您尝试为空引用分配值时,通常会触发未设置对象引用的对象引用.
your first class is not initialized.
so the property is nothing of the first class


object reference not set to an instance of object error is fired generally when you try to assign a value to null reference.


当我通过发送实际this引用作为方法传递时,就解决了争论并在第二堂课中使用该引用.
got resolved as i pass the actual reference by sending (this) as method arguemnt and using that reference in second class.


这篇关于对象引用参考未设置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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