VB.NET || How To Convert A String To Byte Array & Byte Array To String Using VB.NET

Print Friendly, PDF & Email

The following is a module with functions which demonstrates how to convert a string to a byte array and a byte array to a string using VB.NET.


1. String To Byte Array

The example below demonstrates the use of ‘Utils.GetBytes‘ to convert a string to a byte array. The optional parameter allows to specify the encoding.


2. Byte Array To String

The example below demonstrates the use of ‘Utils.GetString‘ to convert a byte array to a string. The optional parameter allows to specify the encoding.


3. Utils Namespace

The following is the Utils Namespace. Include this in your project to start using!


4. More Examples

Below are more examples demonstrating the use of the ‘Utils‘ Namespace. Don’t forget to include the module when running the examples!

QUICK NOTES:
The highlighted lines are sections of interest to look out for.

The code is heavily commented, so no further insight is necessary. If you have any questions, feel free to leave a comment below.

Leave a Reply