How to Convert byte[] to hex string in C# ?

To convert a byte array to hexadecimal string, you can use the BitConverter class in C#.

How to Convert byte[] to hex string in C# ?

Below is a sample code snippet demonstrating how to achieve this.

using System; 
namespace ACConsoleApp 
{ 
    class Program 
    { 
        static void Main(string[] args) 
        { 
            byte[] input = {1, 56, 45, 34, 23}; 
            string hexData = BitConverter.ToString(input); 
            Console.WriteLine(hexData); 
            Console.ReadLine(); 
        } 
    } 
}