You only need to get the bytes if
line[0]=='F'so you should move it inside theifblock.If you only need to get these 3
Int16values, IMHO usingArray.Copy,Array.Reverseis a little bit too much.while(SerialPort.BytesToRead > 50){ string line = SerialPort.ReadLine(); if (line[0]=='F'){ byte[] encoded = enc.GetBytes(line); short value1 = BitConverter.ToInt16(new byte[] {encoded[2] , encoded [1]}, 0); short value2 = BitConverter.ToInt16(new byte[] {encoded[4] , encoded [3]}, 0); short value3 = BitConverter.ToInt16(new byte[] {encoded[6] , encoded [5]}, 0); } }naming variables
value1, value2 and value3screams for new meaningful names and for aList<T>or any other collection. In this way the shown conversation could be done using a loop.comments like
// read line and turn string in byte arraydoes not add any value to the code, because the comment is describing what is done instead of why something is done.
A very good read about comments: http://codereview.stackexchange.com/a/90113/29371https://codereview.stackexchange.com/a/90113/29371