I wonder is there any way can easily convert a String to a byte array in VB.NET?
Printable View
I wonder is there any way can easily convert a String to a byte array in VB.NET?
there is only two easy options:
1. convert your string to char-array
2. convert to base64 string
maybe someone found another easy solution,
good luck
Sascha
That doesn't describe much.Quote:
Originally posted by Sascha
there is only two easy options:
1. convert your string to char-array
2. convert to base64 string
maybe someone found another easy solution,
good luck
Sascha
I think there's an Encoding class in the System.Text namespace. Look on your MSDN help to learn how to use it. The UTF8 encoding class should have the procedure your looking for.
Ahh, here's come code:
Code:Dim strText As String = "This is a test."
Dim btArray() As Byte
btArray = System.Text.UTF8Encoding.ASCII.GetBytes(strText)