Object reference not set to an instance of an object. aCty.MyCitys能获得ArrayList 类的实例吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ArrayList lst = aCty.MyCitys问题可能在两个地方1:aCty是一个null2:MyCitys是一个nulltry--->public ArrayList MyCitys{get{ if (_MyCitys == null) return new ArrayList(); else return _MyCitys;} _MyCitys 是对应于你的属性MyCitys的私有变量 aCty.MyCitys能获得ArrayList 类的实例的 public ArrayList MyCitys{ get { if(m_MyCitys == null) { ArrayList m_MyCitys = new ArrayList(); m_MyDM.FetchCountryCitys(this.EntityID,m_MyCitys); } return m_MyCitys; }}我是这样做的. 这么写//ArrayList lst = aCty.MyCitys; 注释掉if(aCty == null){ MessageBox.Show("aCty is null");}else if( aCty.MyCitys == null){ MessageBox.Show("aCty.MyCitys is null");} public ArrayList MyCitys{ get { if(m_MyCitys == null) { m_MyCitys = new ArrayList(); m_MyDM.FetchCountryCitys(this.EntityID,m_MyCitys); } return m_MyCitys; }}我是这样做的. m_MyDM.FetchCountryCitys(this.EntityID,m_MyCitys); 断点跟踪 谢谢大家,我知道是什么地方出问题了.很简单的一个问题. m_MyDM 为 NUll 我没注意. 再次谢谢. 每个人都给点分. 哈哈... 各位,TabControl控件最多能添加多少个Tabpage啊? 请问大家一个问题啊。关于进程的问题,谢谢啊,请大家帮帮忙,我是新手啊 用户自定义控件问题!急... winform程序中的代码重用问题? C#操作Excel生成柱状图,分不够再加 c# 获取当前系统中所有用户信息 请问winform C # 怎么获得Client的真实IP asp.net里怎么做的让用用户好选择打印机? C#.NET与C++.NET有什么区别 微软专家和c#高手请进:C#接收邮件问题和邮件内容分析? C#中如何在windows应用程序里获取文件路径 SqlHelper 问题
问题可能在两个地方
1:aCty是一个null
2:MyCitys是一个nulltry--->
public ArrayList MyCitys
{
get{
if (_MyCitys == null) return new ArrayList();
else return _MyCitys;
}
{
get
{
if(m_MyCitys == null)
{
ArrayList m_MyCitys = new ArrayList();
m_MyDM.FetchCountryCitys(this.EntityID,m_MyCitys);
}
return m_MyCitys;
}
}
我是这样做的.
//ArrayList lst = aCty.MyCitys; 注释掉if(aCty == null)
{
MessageBox.Show("aCty is null");
}
else if( aCty.MyCitys == null)
{
MessageBox.Show("aCty.MyCitys is null");
}
{
get
{
if(m_MyCitys == null)
{
m_MyCitys = new ArrayList();
m_MyDM.FetchCountryCitys(this.EntityID,m_MyCitys);
}
return m_MyCitys;
}
}
我是这样做的.
断点跟踪
很简单的一个问题. m_MyDM 为 NUll 我没注意.
再次谢谢. 每个人都给点分. 哈哈...