我有一個問題,通過BitConverter.ToInt32將字節數組轉換爲int32。轉換字節數組爲int32
類型「System.ArgumentException」的未處理的異常出現在mscorlib.dll的
附加信息:目標數組不夠長,所有項目複製>收藏。檢查陣列索引和長度
private void textBox2_TextChanged(object sender, EventArgs e)
{
byte[] StrToByte = new byte[9];
int IntHexValue;
StrToByte = Encoding.UTF8.GetBytes(textBox2.Text);
textBox4.Text = BitConverter.ToString(StrToByte);
IntHexValue = BitConverter.ToInt32(StrToByte, 0);
}
爲什麼你分配一個9字節數組,然後忽略它? (你正在爲'StrToByte'分配一個新的值。)'textBox2.Text'的內容是什麼?這並不完全清楚你想在這裏實現什麼。 –
'textBox2.Text'的值是什麼? –
@SonerGönül,爲什麼?你在尋找其他的shell命令嗎? ':)' – gdoron