Results 1 to 3 of 3

Thread: String to byte array

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Posts
    37

    String to byte array

    I wonder is there any way can easily convert a String to a byte array in VB.NET?

  2. #2
    New Member
    Join Date
    Sep 2002
    Location
    Vienna
    Posts
    13
    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

  3. #3
    Hyperactive Member
    Join Date
    Feb 2002
    Posts
    261
    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
    That doesn't describe much.

    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)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width