你这行再不写就可以出错了:)
_mJ = new MatchedJob[ myAL.Count ];

解决方案 »

  1.   

    这样不对吧,一个class element in array, 必须被初始化的吧,而且我也试过没初始化就会出错的在别的程序中,可是这里没错。
      

  2.   

    不好意思,没细看你的代码
    (MatchedJob)myEnumer.Current已经返回一个instance了
      

  3.   

    哦这样能够理解,不过,。。不好意思,这个问题和另一个问题是并发的,所以我昏头了
    在同一个类中(我这个类是用来当webservice的)有这么个函数,调用的时候就出现instan access错误,不管我写了new element[i]或者没写都一样 [ WebMethod ( Description = "get all registered inc. informations from database, the result is a array of IncInformation class, the returned int value identify the number of records recrieved " ) ]
    public int GetAllIncInformation ( out IncInformation[] _iI )
    {
    string [] incID ;
    int t = GetAllIncID( out incID );
    _iI = new IncInformation [t];
    for ( int i = 0; i <= t -1; i++)
    {
    _iI[i] = new IncInformation();//这里不管写了还是没写都错误啊
    GetIncInformation ( incID[i], out _iI[i] );
    }
    return t;
    }
      

  4.   

    _iI[i] = new IncInformation();//这里是肯定不用写这句话的了,如果你的GetIncInformation能够编译通过的话。 }GetIncInformation如果没有没有new _iI[i],带out就编译不过了
      

  5.   

    我完全明白清楚了,但是问题我还是找不出在哪里?
    我把这两个函数都写出来吧:
    public int GetAllIncInformation ( out IncInformation[] _iI )
    {
    string [] incID ;
    int t = GetAllIncID( out incID );
    _iI = new IncInformation [t];
    for ( int i = 0; i <= t -1; i++)
    {
            GetIncInformation ( incID[i], out _iI[i] );
    }
             return t;
    } public bool GetIncInformation ( string _incID, out IncInformation _ii )
    {
    if ( ! ExistIncID( _incID ) )
    {
    _ii = new IncInformation();
    return false;
    };
    string commaStr = "select addInfo, email, incAtt, incHomepage, incLoc, incName, ID, phone, PW from incInformation where ID = " + "'" + _incID + "'";
    myCommand.CommandText = commaStr;
    SqlDataReader myReader = myCommand.ExecuteReader();
    IncInformation ii = new IncInformation();
    myReader.Read() ; if ( ! myReader.IsDBNull(0) )
    ii.addInfo = myReader.GetString(0);
    if ( ! myReader.IsDBNull(1) )
    ii.email = myReader.GetString(1);
    if ( ! myReader.IsDBNull(2) )
    ii.incAtt = myReader.GetString(2);
    if ( ! myReader.IsDBNull(3) )
    ii.incHomepage = myReader.GetString(3);
    if ( ! myReader.IsDBNull(4) )
    ii.incLoc = myReader.GetString(4);
    if ( ! myReader.IsDBNull(5) )
    ii.incName = myReader.GetString(5);
    if ( ! myReader.IsDBNull(6) )
    ii.ID = myReader.GetString(6);
    if ( ! myReader.IsDBNull(7) )
    ii.phone = myReader.GetString(7);
    if ( ! myReader.IsDBNull(8) )
    ii.PW = myReader.GetString(8); myReader.Close();
    _ii = ii;
    return true;
    }
      

  6.   

    两种return你都new了
    _ii = new IncInformation();
    return false;IncInformation ii = new IncInformation();
    。。
    _ii = ii;
    return true;
      

  7.   

    终于给我发现了,是没有把SqlDataReader给close。。真是太谢谢你了,谢谢谢谢谢谢我好象只有10分不好意思哈哈,我很多问题经常没分的大哥赏脸我们做个朋友吧[email protected]