How to convert string to byte array in c#

{0 Comments}

To convert string to byte array in c# we use GetBytes() method here we pass string as parameter and it return converted byte array of given string you can use following syntax to convert string to byte array. To use get byte method you need to first include system.text namespace. 

 C# |  copy code |? 
1
byte[] array = Encoding.ASCII.GetBytes(input);

Leave a Comment

Your email address will not be published.