I am reading from serial port using string messaga = _serialPort.ReadLine();
When i Console.WriteLine(messaga); random characters appear on the screen which is logical because the binary data is non ASCII.
I suppose the method I am using handles data as ascii.
What i would like to do is create a string var and asign to it the binary raw data coming from the port so when I console.write this var I want to see a string with binary data like 1101101110001011010 and NOT characters. How can i manage that?
I am reading from serial port using string messaga = _serialPort.ReadLine(); When i Console.WriteLine(messaga);
Share
You mean like this?
Benchmarked this just now. The above code is approximately 12x faster than using
Convert.ToString()and approximately 17x faster if the correction is added to pad with leading ‘0’s.