VB.net RecDataStr = Encoding.ASCII.GetString(bytes, 0, bytesRec) 我得到了RecDataStr , 哪又如何把RecDataStr 再转换为bytes这个对象
时间: 2024-02-01 10:13:42 浏览: 14
你可以使用 Encoding.ASCII.GetBytes 方法将 RecDataStr 转换回字节数组。示例代码如下:
```
Dim bytes As Byte() = Encoding.ASCII.GetBytes(RecDataStr)
```
其中,`bytes` 就是转换后的字节数组。
相关问题
VB.net RecDataStr = Encoding.ASCII.GetString(bytes, 0, bytesRec) 我得到了RecDataStr , 哪又如何把RecDataStr 再转换为Byte
你可以使用Encoding.ASCII.GetBytes()方法将RecDataStr转换为byte数组:
```
Dim bytesToSend As Byte() = Encoding.ASCII.GetBytes(RecDataStr)
```
其中,bytesToSend即为转换后的byte数组。
VB.net RecDataStr = Encoding.ASCII.GetString(bytes, 0, bytesRec) 我得到了RecDataStr , 我又如何将RecDataStr 转换为byte , 而且得到的Byte数组会等于我的原始数组bytes
你可以使用 `Encoding.ASCII.GetBytes()` 方法将字符串 `RecDataStr` 转换为字节数组。具体实现如下:
```vb
Dim bytes As Byte() = Encoding.ASCII.GetBytes(RecDataStr)
```
这样就可以得到与原始数组 `bytes` 等值的字节数组了。
相关推荐
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)