How to convert string to Byte array in c#

This is very simple code showing how to convert string to byte array in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Blog_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            const string message = "the quick brown fox jump over the lazy dog";
            byte[] bytes = Encoding.Default.GetBytes(message);
            Print(bytes);
        }

        private static void Print(byte[] bytes)
        {
            Console.WriteLine(String.Join(",", bytes));
        }
    }
}

No comments:

Post a Comment