private byte[] ConvertStringtoByte(String str)
{
if (!String.IsNullOrEmpty(str))
return System.Text.Encoding.ASCII.GetBytes(str);
return null;
}
If you have any questions let me know :)
Code Snippet - To convert String to Byte Array in C#
It's easy to convert a string to a byte array. For an ASCII string, use the System.Text.Encoding.ASCII.GetBytes static method.
Code Snippet example below :