C# binary data conversion to string

后端 未结 1 1872
野趣味
野趣味 2021-01-24 13:33

Here is the deal. I found a source code and changed it a little bit so i can retrieve data from a receiver that is on com6. The data i am receiving is binary. What i want is to

相关标签:
1条回答
  • 2021-01-24 14:08

    Data from ports will always come in binary(bytes), therefore it depends on how to interpret the data. Assuming that the bytes are ASCII, you can encode it to a string as follows:

    byte[] binaryData ; // assuming binaryData contains the bytes from the port.
    
    string ascii =  Encoding.ASCII.GetString(binaryData);
    
    0 讨论(0)
提交回复
热议问题