Earn income with your C# skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest self-service freelancing marketplace for people like you.

How to convert a string to a byte array in C#

The Encoding.GetBytes() method converts a string into a bytes array. The example below converts a string into a byte array in Ascii format and prints the converted bytes to the console.


string author = "Katy McClachlen";

// converts a C# string to a byte array

byte[] bytes = Encoding.ASCII.GetBytes(author);

foreach (byte b in bytes)
{
   Console.WriteLine(b);
}



Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0