ASCII到Base32 [英] ASCII to Base32
问题描述
我正在努力将vb项目中的文本框中输入的10个字符转换为Base32.这是我的代码.我收到一个错误 类型'String'的值不能转换为'Byte()'. WindowsApplication2
I am working at making what 10 characters go into a text box in my vb project convert into Base32. Here is my code. I am getting an error Value of type 'String' cannot be converted to 'Byte()'. WindowsApplication2
Private Sub Ok_Click(sender As Object, e As EventArgs) Handles Ok.Click
Dim DataToEncode As Byte() = txtbox.Text
Dim Base32 As String
Base32 = DataToEncode.ToBase32String()
Auth.Text = Base32
End Sub
推荐答案
txtbox.Text
中的值是一个字符串,不能自动转换为字节数组.因此,Dim DataToEncode As Byte() = txtbox.Text
行无法编译.要获取字符串的ASCII表示形式,请使用
The value in txtbox.Text
is a string which can't be automatically converted to a byte array. So the line Dim DataToEncode As Byte() = txtbox.Text
can't be compiled. To get the ASCII representation of a string use the System.Text.Encoding.ASCII.GetBytes()
method.
Dim DataToEncode As Byte() = System.Text.Encoding.ASCII.GetBytes(txtbox.Text)
VB.Net中的字符串也不存储ASCII值,它们使用UTF-16.
Also strings in VB.Net do not store ASCII values, they use UTF-16.
这篇关于ASCII到Base32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!