How to convert string to Byte array in c#

This is very simple code showing how to convert string to byte array in c#

# How to convert byte array to string 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));
        }
    }
}

Post a Comment

Please do not post any spam link in the comment box😊

Previous Post Next Post

Blog ads

CodeGuru