Thursday, 5 April 2018

Convert byte array to string and string to byte array using c#

Description : In this post how to convert a simple string into byte array or convert a byte array to string using c#. this code is use in my early post for Download file from FTP.

- Below code for convert string to byte array using c#

string stringToConvert = "Hello World !";

byte[] buffer = Encoding.UTF8.GetBytes(stringToConvert);

- Below code for convert byte array to string using c#

string converted = Encoding.UTF8.GetString(buffer, 0, buffer.Length);

No comments:

Post a Comment