System.NullReferenceException:对象不设置到对象的实例 [英] System.NullReferenceException: Object reference not set to an instance of an object
本文介绍了System.NullReferenceException:对象不设置到对象的实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能显示的文件:
的什么是.NET中一个NullReferenceException?
的 System.NullReferenceException:对象不设置到对象的实例
我使用下面的代码
public partial class SectionControls_SingleBanners : SectionControlBaseClass
{
private SingleBanners _section;
protected void Page_PreRender(object sender, EventArgs e) {
updateViews();
if (RssCapable(this._section.GetType()) && _section.BannersEntries.Rows.Count > 0) {
所以这里这个代码我收到错误
So here on this code I am getting the error
this._section.GetType();
如何解决这个问题可以解决吗?
How can this problem be fixed?
推荐答案
您不能执行,这不是一个实例化对象的非静态方法
You can't execute a non-static method on a object that wasn't instantiated.
试试这个:
private SingleBanners _section = new SingleBanners();
这篇关于System.NullReferenceException:对象不设置到对象的实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文