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个字节的
[解决办法]