问题是这样的:
定义一个返回值为数组的方法:
 public int[] aa(int b)
{
  int []re= null;
  re[0]=b;
  re[1]=b+1;
  return re;
}在调用类中
int []bb=obj.aa(10);
label1.text=bb[0].ToString ();  //这步的时候会出错?错误信息为:Object reference not set to an instance of an object.请各位帮我解释下

解决方案 »

  1.   

    int []re= null;没实例化就敢赋值?
      

  2.   


    int []bb=obj.aa(10);
     这里只有一个值吧?
      

  3.   

    int []re= null;都没有分配空间,就赋值re[0]=b;
      re[1]=b+1;
    可以?
      

  4.   


            public int[] aa(int b)
            {
                int[] re = {0,0};
                re[0] = b;
                re[1] = b + 1;
                return re;
            }
      

  5.   

    都没有实例化。。
      int []re= new int[2];
      

  6.   

    int []re= new int[2];
      

  7.   


    int[] re=new int[2];
    re[0]=b;
    re[1]=b+1;
    return re;
      

  8.   

    或者:public void test(int b,ref re[])
    {
      re[0]=b;
      re[1]=b+1;
    }但re也要在函数外实例化