在VB.NET中如果需要将一个字符串转换成字节数组,可以使用System.Text命名空间中某个编码对象的GetBytes方法。
Dim strText As String = "This is an original string"
Dim encText As New System.Text.UTF8Encoding()
Dim btText() As Byte
btText = encText.GetBytes(strText)
MessageBox.Show("The total number of encoded bytes is: " & btText.Length.ToString())
评论