Advertisement
ZeekoSec

Bytes in VB.NET

Apr 9th, 2015
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' String to byte
  2.  
  3.  
  4. ' Native C# strings are unicode encoded
  5. Dim StringMessage As String = "Hello World How Are you? Pi π Yen ¥"
  6.  
  7. ' We can show the characters on the command line
  8. Console.WriteLine("{0}", StringMessage)
  9.  
  10. ' We can convert directly a byte array, but some information is lost
  11. Dim ASCII As New System.Text.ASCIIEncoding()
  12. Dim BytesMessage As [Byte]() = ASCII.GetBytes(StringMessage)
  13.  
  14. ' Byte back to string
  15.  
  16. Dim BytesMessage As [Byte]()
  17. ' Your message
  18. Dim ASCII As New System.Text.ASCIIEncoding()
  19. Dim StringMessage As [String] = ASCII.GetString(BytesMessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement