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));
        }
    }
}

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

إرسال تعليق (0)
أحدث أقدم