首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C# 流数组长度不足。请检查 srcIndex 和长度以及数组的下限

2014-01-17 
C#源数组长度不足。请检查 srcIndex 和长度以及数组的下限。 string strConn Data Source127.0.0.1Init

C# 源数组长度不足。请检查 srcIndex 和长度以及数组的下限。
 string strConn = "Data Source=127.0.0.1;Initial Catalog=zy;User ID=sa;Password=229107my229107m";
                        SqlConnection ConnAcc = new SqlConnection(strConn);
                        string strSQL = "SELECT * FROM Group_SGK3 ";
                        SqlDataAdapter de = new SqlDataAdapter(strSQL, ConnMdb);
                        try
                        {
                            //da.Fill(dt);
                            dtData.Clear();
                            de.Fill(dtData);

                        }
                        catch
                        {
                            break;
                        }
                            for (int n = 0; n < 7; n++)
                            {
                                int GK;
                                foreach (DataRow rdr in dtData.Rows)
                                {

                                    int SGK = Convert.ToInt32(rdr["SGK"]);
                                    GK = SGK << n;

                                    
                                        if (Convert.ToBoolean(rdr["state1"]))
                                        {
                                           

                                            byte[] gk = new byte[8];
                           Array.Copy(HexStrToHexBytes(GK.ToString()), 0, gk, 7, 1);
     Array.Copy(HexStrToHexBytes(dr["pdk"].ToString()), 0, pdk, 7, 1);// pdk buf: 0,0,0,0,0,0,0,0xcd
                                            ;


                                            SKeyValue = SKeyValue1;
                                            byte[] EncryptSk = EncryptDES(SKeyValue, gk);
                                           

                                            EDS[6] = 0x01;
                                            Array.Copy(EncryptSk, 0, EDS, 7, EncryptSk.Length);
                                            //Thread.Sleep(5);
                                        }
                                        else
                                        {


请问: Array.Copy(HexStrToHexBytes(GK.ToString()), 0, gk, 7, 1);这行提示错误说“源数组长度不足。请检查 srcIndex 和长度以及数组的下限。”这是怎么回事呢?应该怎么改?请各位大师指点!
值为1这怎么够字节啊,int是占4个字节的
[解决办法]


如果你的数组只有5个字节(比如说),你让array.copy从第8个字节开始拷贝一个字节,那显然出错。

热点排行