我在Visual Studio 2010中使用C#。
我想将一个字节(8位整数)转换为一个字符长的字符串。我需要这样做,因为我想通过串行将字节值发送到Arduino。
例如,假设
byte myByte = 49;
49是字符“ 1”的ASCII码。我想将myByte转换为myString,这样我就可以了
serialport1.Write(myString);
它的功能与
serialport1.Write("1");
谁能帮我吗?
System.Text.Encoding.ASCII.GetString(new[]{myByte})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句