Upon tick of my timer i am reading 9 byte of data from my sensor, i am converting the read string to HEX form the data is 01-03-04-0A-D5-15-A9-26-FD right now the only data concerned with me is 4th & 5th element i am using split command to split my string but still i am unable to access exception pops out Indexoutofrangeexception, when itry to access 4th element by index 3,
private void timer1_Tick(object sender, EventArgs e)
{
// timer1.Enabled = false;
serialPort1.Write(query, 0, query.Length);
incoming = serialPort1.ReadExisting();
ba = Encoding.Default.GetBytes(incoming);
var hexString = BitConverter.ToString(ba);
textBox1.Text = incoming;
textBox2.Text = hexString;
string[] splittedResult = hexString.Split('-');
textBox3.Text = splittedResult[3];
//label1.Text = splittedResult[1];
// textBox3.Text = Convert.ToString(hexString.Length);
timer1.Enabled = true;
}