Friday, 10 October 2014

How to convert string to byte[ ]?

 To convert a string to byte[ ] write the following code:

string stringToConvert="Input your string here";
ASCIIEncoding aEncoding = new ASCIIEncoding();

byte[] bytes = new byte[stringToConvert.Length];

//Convert string message to byte[]

bytes = aEncoding.GetBytes(stringToConvert);
 

No comments:

Post a Comment